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

help writing a select statement 1

Status
Not open for further replies.

newprogamer

Programmer
Sep 22, 2004
107
0
0
US
I am getting the data from an access database. How do I write a select statement that will return any values (like) that starts with the same letters the user enters into a combo box. This is the code I am using. But, it only returns the exact match. Please help!

If cboModel.Value <> "" Then strSelect = "SELECT Quote, Manufacturer, Type, Model, WordQuote FROM tblFileName WHERE Model LIKE '" & cboModel.Value & "'"

Thanks,
new programmer
 
If cboModel.Value <> "" Then strSelect = "SELECT Quote, Manufacturer, Type, Model, WordQuote FROM tblFileName WHERE Model LIKE '" & cboModel.Value & "*'"
 
Thanks Golom, but that did not work. It went to the Adodc1.Recordset.EOF and found no records.

Any other suggestions, please!
 
check to make sure that your list box is returning only the letter that is selected and not more, and that there is no space between the quote and the asterisks. those are simple problems but Otherwise Golom's should work.



Walt III
SAElukewl@netscape.net
 
Thanks for your help. It should be easy, but it's not for me. Here are the results of my select statement. This is using debug.print = strSelect. Any more help would be appreciated!

SELECT Quote, Manufacturer, Type, Model, WordQuote FROM tblFileName WHERE Model LIKE 'model*'

SELECT Quote, Manufacturer, Type, Model, WordQuote FROM tblFileName WHERE Model LIKE 'mod*'

 
Golom's statement should work. try isolating your problem. Instead of evaluating the value of cboModel with the If statement, just try to build the SQL statement that works.

Once your SQL statement works, then apply logic to ensure there's a valid value in cboModel
 
If in ADP (instead of MDB) or if ADO (instead of DAO) then:
strSelect = "SELECT Quote, Manufacturer, Type, Model, WordQuote FROM tblFileName WHERE Model LIKE '" & cboModel.Value & "[red]%[/red]'"


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top