Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Visual Basic SQL Statement not working

Posted on 2003-03-22
2
Medium Priority
?
166 Views
Last Modified: 2013-11-25
Here is the statement:

dbMembers.RecordSource = "select * from Members Where Name like 'Lea%'"
dbMembers.Refresh

I have a table of Members, I want the user to be able to enter a name to search for, and all matches to be displayed on a flexgrid I have in my project bound to this database, unfortunatly while testing with the above lines of code I find it does not work, I have the database and in it under the Name field in the Members table is the name Leanne Stockwell, but the SQL above brings up a blank recordset?

I have even tried replacing 'Lea%' with '%e%' AND STILL I GET A BLANK RECORDSET???

According to every SQL and Visual Basic SQL tutorial I could find the above statement 'should' work, is there something i'm doing wrong here?

I thank you all in advance for any light you can shed on this problem !!

Please note: if I execute the code with just "select * from Members" as the recordsource I get the whole database displayed in the FlexGrid, so I KNOW I havnt done anything wrong with the data control itself.

0
Comment
Question by:shnads
2 Comments
 
LVL 39

Accepted Solution

by:
appari earned 200 total points
ID: 8186181
whats the database?
if it is Access and you are using DAO then try '*' as wild card character instead of '%'

try changing
dbMembers.RecordSource = "select * from Members Where Name like 'Lea%'"
dbMembers.Refresh
to
dbMembers.RecordSource = "select * from Members Where Name like 'Lea*'"
dbMembers.Refresh
0
 

Author Comment

by:shnads
ID: 8189224
Thankyou so much appari, I just wish that was better documented so I could have saved myself all this stress !!!

once again, thankyou :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question