search in a form

A

AKA Sparkticus

I a trying to do a search in a form from a drop down list but also want to
have a wildcard search so I cant type in some of the title....

I have got the search working but can not get the wild card to work...

any idea what I need to add to to code
Private Sub Find_Records_Click()
Dim findByNameSQL As String

If IsNull(Me.criteria) Then
MsgBox "Please enter customer forename to search", , "Kitchen Database"
Me.criteria.SetFocus
Exit Sub
End If
****** this code works for a basic search but not sure it is quite right
******************
------what will i need to change to get it to work as a wild card seach
rathger tghen a full text search--------
findByNameSQL = "SELECT * FROM contractors WHERE Contractors_Comp_Name LIKE
"
findByNameSQL = findByNameSQL + "'" + Me.criteria + "'"


Me.RecordSource = findByNameSQL
If Contractors_Comp_Name.Text = "" Then
MsgBox "No records matching the criteria", vbExclamation, " Database -
Contractor Search"

End If

End Sub


many Thanx
 
J

John Spencer (MVP)

Try adding the wild card characters when you are building the SQL string.
Something like:

findByNameSQL = findByNameSQL + "'*" + Me.criteria + "*'"

OR entering the wildcard characters in the Criteria box if you want greater
control. If you are not using DAO then you may need to use % instead of * as
the wild card characters.
 
A

AKA Sparkticus

Thanx for your help...
I was putting the wild card in wrong "'*'"+ you have set me right...
Again many Thanx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top