-
SQL Query
Hi,
I have created a few tables and am having problems with a search that i added to the form.
In short, I wish to display only records that have an exact match. At the moment, I have the following:
Dim strsearch As String
Dim txtSearch As String
strText = Me.txtKeyword.Value
strsearch = "SELECT * FROM CLAIM WHERE ((ID LIKE ""*" & strText & "*""))"
Me.RecordSource = strsearch
If I enter '6' in the search box, the results will display all records that contain the number 6. What is the correct query to display just the record with id 6? (without 16, 26, 36, 60 etc..)
Thank you in advance.
-
strsearch = "SELECT * FROM CLAIM WHERE ID ='" & strText & "'"
This assumes that the field ID is actually text and not a number
-
I think this is where I am going wrong, ID = number (autonumber)
What do I need to change to get it to work?
Thanks again for your help!
-
strsearch = "SELECT * FROM CLAIM WHERE ID =" & strText
-
Thank you @ Ajax. Seems the first query worked just fine.
strsearch = "SELECT * FROM CLAIM WHERE ((ID ='" & strText & "'))"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules