| View previous topic :: View next topic |
| Author |
Message |
whythetorment Newbie
Joined: 22 Apr 2005 Posts: 3
|
Posted: Apr 22nd, 2005 12:32 PM Post subject: Find Records |
|
|
Hi
Im absolutely new to VB. Only been programming in it about a week now...so please bear with me =D
I have a text box on my form (EditSurname). Then when user enters the first letter of the surname, a DBGrid comes up with all the surnames starting with that letter (or it should). Im having trouble with the Find method. My code:
VRRS.rsClients.Find "Surname Like '" & EditSurname.text & "'"
Now if the surname only has one letter like 'e', then it looks it up. But when i have a surname like 'abc' or even 'ab'...then it doesnt find it? (PS: only sample data). It only locates one letter surnames in my database.
So i tried using '*' but then it says Type mismatch or something like that.
Any help please =D |
|
| Back to top |
|
TriSight Regular
Joined: 12 Oct 2004 Posts: 69 Location: Mobile, AL
|
Posted: Apr 22nd, 2005 01:32 PM Post subject: |
|
|
It depends on what type of database you are using.. the common wildcards for the LIKE statement are % and _ when you are dealing with most modern databases. I don't know about the modern versions of access but the two wildcards used above were * and ? respectively.
so if you wanted to find everything that started with the word "This" you could use " LIKE 'This%' or '%This%' would find everything that had This in it (including if you had TestThis (one word), it would find this also, you would use '% This %' if you only wanted the word This with spaces around it).
% = wildcard *
_ = single character wildcard (or ?)
try that and tell me how that works. _________________ /=--_The Nomad_--=\
"Men of lofty genius when they are doing the least work are most active. " - Leonardo da Vinci
Last edited by TriSight on Apr 26th, 2005 08:43 AM; edited 1 time in total |
|
| Back to top |
|
whythetorment Newbie
Joined: 22 Apr 2005 Posts: 3
|
Posted: Apr 25th, 2005 03:20 AM Post subject: |
|
|
Thanx =D
The % worked perfect.
Thanx alot |
|
| Back to top |
|
TriSight Regular
Joined: 12 Oct 2004 Posts: 69 Location: Mobile, AL
|
Posted: Apr 26th, 2005 08:42 AM Post subject: |
|
|
No problem :-) _________________ /=--_The Nomad_--=\
"Men of lofty genius when they are doing the least work are most active. " - Leonardo da Vinci |
|
| Back to top |
|
|