This may seem easy to most of you...
I have a simple database, storing Name, Company and Telephone number.
I have a form showing the three fields info as labels. I have four buttons called FIRST, PREVIOUS, NEXT and LAST to navigate through the names, (thereby showing the relevant Company and Telephone number)

Now the required bit...

I also want to be able to search by Name or Company. Preferably this is achieved by clicking on a "Search" button and an input box appears (or similar) and even if entering a partial name will provide possible results. Eg If I type in "dav" will show any David's etc

Does any one have a "standard" piece of code with this facility I could try and adapt, as I would imagine that this type of search is used widely in database projects

Any help / ideas would be of great benefit

Thanks in advance,

Kenny

Private Sub mnufind_Click()
Dim a As String
Dim b As String


a = InputBox("Enter name or first few letters what you want to find: ", "Find")
If Len(a) = 0 Then Exit Sub
b = "Name Like """ & a & "*"""
Data1.Recordset.FindNext b
If Data1.Recordset.NoMatch Then
MsgBox "No record found", vbExclamation, "Phone Book"
End If
Exit Sub

End Sub

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.