SunQuest
           Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 13th, 2003, 10:59 PM
utmostrusselb utmostrusselb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Canada
Posts: 40 utmostrusselb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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

Reply With Quote
  #2  
Old July 13th, 2003, 11:13 PM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
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 & "*'"

Reply With Quote
  #3  
Old July 14th, 2003, 08:27 AM
utmostrusselb utmostrusselb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Canada
Posts: 40 utmostrusselb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Perfect.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > VB Query Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway