I am new to this board and also new to access so I will try to be detailed as possible. I have also been reading other posts and have finally at least got a search, but just not like I want.
I have a database called Master Name Index. This database has approx. 10K names in it. I want to search the records by FirstName, LastName, and DOB.
I would like to create a form that has a text box, button, and list box. I would also like to have the user type in the Text box a first name, last name, or dob and then the results show up in the list box so that the user can click on the correct result and go to the form containing the records(Master Name Index).
Main Form is Called Master Name Index
Fields I would like to search are called LastName, FirstName, and DOB.
I am currently using this code but it does not allow the results to go to a list box. Would it be possible to use this code or would I have to use a differant one.
Private Sub Command2_Click()
On Error GoTo Err_Command61_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Master Name Database"
stLinkCriteria = "[LastName] LIKE " & "'*" & [Text0] & "*'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
.OrderByOn = True
.OrderBy = "LastName"
As a matter of efficienct Access VBA coding, do not use spaces in source or object name, it complicates codes. Also consider using the "Hungarian" naming convention for controls. Days after codiong, the programmer will forget the datatype of a control. Google "Hungarian naming convention" for the (prefixt) notation.