Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Criteria

Status
Not open for further replies.

neilmcmor

Technical User
Aug 9, 2007
30
GB
I have a button that when clicked on the form allows the user to type a surname and searc the database. however at present the full surname must be typed correctly. I would like for it to be able to search with only part of the surname being entered. How could I change the following code to support 'Like'?

Function OpenFindBySurnameForm()
On Error GoTo OpenFindBySurnameForm_Err

' Close the form
DoCmd.Close acForm, "PrisonersBySurname"
' re-open the form to allow passing of parameters
DoCmd.OpenForm "PrisonersBySurname", acNormal, "", "", , acNormal


OpenFindBySurnameForm_Exit:
Exit Function

OpenFindBySurnameForm_Err:
MsgBox Error$
Resume OpenFindBySurnameForm_Exit

End Function
 
I cannot quite see what the above line does. You need to include a valid Where statement. For example:

[tt]"Surname Like '*" & Replace(Me.txtSearch."'","''") & "*'"[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top