|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
VB Query Problem
HI, I am sure that the answer to this problem is posted somewhere. Damned if I can find it. It is a simple syntax problem. I have a VB front end and I want to query an Access database. I need the syntax for the Like operator. I need this query to fill a grid. For instance, if a person types in the first three letters of a last name, the query returns all of the close matches. Here is what I have and it doesn't give a near match:
Set Rst = db.OpenRecordset("SELECT * FROM TBMAIN WHERE PHN Like 'strsearch*'", dbOpenSnapshot, dbReadOnly) StrSearch is a text box value. I have tried both * and %. Remember that the code is in Visual Basic, not Access. Thanks a million in advance!
__________________
Best regards, Russ Bergen Senior Software Developer and Webmaster |
|
#2
|
|||
|
|||
|
The LIKE operator in MS Access is '*'.
Thus you have SELECT * FROM tbmain WHERE PHN LIKE '713*' ... This will work if the field is alphanumeric. I am not sure that MS Access allows wildcard searches on numeric fields. ... If you are passing in a variable you will need to do this. LIKE '" & strsearch & "*'" |
|
#3
|
|||
|
|||
|
Perfect.
|
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > VB Query Problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|