Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting

Post new topic   Reply to topic
Find Records
View previous topic :: View next topic  
Author Message
whythetorment
Newbie


Joined: 22 Apr 2005
Posts: 3

PostPosted: Apr 22nd, 2005 12:32 PM    Post subject: Find Records Reply with quote

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
View user's profile Send private message
TriSight
Regular


Joined: 12 Oct 2004
Posts: 69
Location: Mobile, AL

PostPosted: Apr 22nd, 2005 01:32 PM    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
whythetorment
Newbie


Joined: 22 Apr 2005
Posts: 3

PostPosted: Apr 25th, 2005 03:20 AM    Post subject: Reply with quote

Thanx =D

The % worked perfect.

Thanx alot
Back to top
View user's profile Send private message
TriSight
Regular


Joined: 12 Oct 2004
Posts: 69
Location: Mobile, AL

PostPosted: Apr 26th, 2005 08:42 AM    Post subject: Reply with quote

No problem :-)
_________________
/=--_The Nomad_--=\
"Men of lofty genius when they are doing the least work are most active. " - Leonardo da Vinci
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic