Help with a Search Function

PapaWhiskey

New member
Local time
Today, 12:38
Joined
Jan 14, 2009
Messages
6
I need a little help on a project I am working on.

I am creating a directory system to work with thousands of records that are in the data table keeping track of people, and their information.

The problem I am having at the moment is creating a search function that will allow me to search for any part of the last name, and/or any part of the first name at the same time to narrow down for the common last names.

I have a search that will go with P.O. Box #, but to use both last and first names is giving me some problems.

Any help on this would be greatly appreciated.



V/R
PW
 
Welcome to the site. What have you got so far?
 
I was reading one of the other posts and used information from that for the search
This worked when I used it for the box search.
this one i tried to use for just "Last Name" search, and it doesn't even work correctly.
I want to try to get both first and last name to work together to narrow the search down.
I am new to access so, that probably the first problem :)

Private Sub results_DblClick(Cancel As Integer)

Dim rs As Object
DoCmd.OpenForm "frmViewdirectory"

Set rs = Forms!frmviewdirectory.Recordset.Clone
rs.FindFirst "[LNAME] = " & Str(Nz(Me![results], 0))
If Not rs.EOF Then Forms!frmviewdirectory.Bookmark = rs.Bookmark
DoCmd.Close acForm, Me.lname

End Sub

Private Sub txt_ser_Change()
Dim str_search As String

str_search = Me.txt_ser.Text
Me.txt_ser_2.Value = str_search
Me.results.Requery
End Sub
 
Last edited:
To get the one field to perform your search on concatenate the first and last names in the underlying query. For example FULLNAME: FNAME & " " & LNAME

Then you can use something like:

rs.FindFirst [FULLNAME] Like "*" & Me.txtSearchField & "*"
 
If that's actually a text field as it would appear, it would need to be surrounded by single quotes. There's a nice tutorial here along with a sample db that demonstrates one method to allow the user to search with optional fields:

http://www.mdbmakers.com/forums/showthread.php?t=4895
 
That was very helpful, I got the information I needed from that site.
Thank you for the help!

V/R
PW
 

Users who are viewing this thread

Back
Top Bottom