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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need SQL to retrieve if input is at start of field 1

Status
Not open for further replies.

TeresePamela

Programmer
Sep 4, 2003
40
US
I have been working from the searchdb.mdb that I "found" on this forum and can't find again to give multiple stars - it's a Gem. :)

I have modified it to suit my needs and it's perfect, but I would like one more enhancement that I don't know how to do. The current SQL retrieves if the user input is anywhere in the field. I'd like to add a checkbox so the user can request that only those records where the input is at the start of the field are retrieved, I would not know how many characters were entered. I was going to do an If-Then-Else based on the value of the checkbox. If the user wants the data from anywhere in the field the code is:

strwhere = "WHERE"
If Not IsNull(Me.descript) Then
strwhere = strwhere & " (GIData.Descript) Like '*" & _
Me.txtdescript & "*' AND"
strorder = "ORDER BY GIData.Descript;"
End If

My question is: What is the SQL to retrieve only if the input is at the start of the field?

As always, any and all input is appreciated.
Pam
 
Get rid of the star at the beginning of the Like argument:
Like '" &

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Wow, you guys are fast. Thanks PHV.

So it would be:

strwhere = strwhere & ( GIData.descript) like '" & Me.txtdescript & "' AND"

?? (i.e. do I need the star at the end of the argument?

Thanks
 
do I need the star at the end of the argument
Yes, except if you want exact match.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks so much PHV. You can't imagine how helpful this is. I can just about wrap this project up and move on to the next one. Learned a great deal about ACCESS with this project and could not have done it without this forum.

Thanks again
Pam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top