Visual Basic SQL Statement not working

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

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

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.

Question by:shnads
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 39

Accepted Solution

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.RecordSource = "select * from Members Where Name like 'Lea*'"

Author Comment

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 :)

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

752 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