Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

FindFirst Method

FindFirst Method

FindFirst Method

When using the FindFirst Method I do not get the expected result for the NoMatch property if: my criteria includes a string. I think this is because I pad any single quotes with a single quote for the SQL statement. Has anyone else had a similar problem?

RE: FindFirst Method

<very puzzled look indeed> Could you post an example of what you mean?


RE: FindFirst Method

Tell me if this is what you mean:

Ex. 1. Recordset.FindFirst "LastName='" & NameVar & "'"
Namevar must be a string variable that does not include quotation marks.

Or if you're not getting results, you may have dealt with numbers or dates which should not br enclosed in single quotes. For dates enclose searchstring in #. like "Date > #" & DateVar & "#".
Or you need to simplify your code to make it look like Ex.1 above.
Or maybe we can look at your sample code bec. I have to agree with Mike.

RE: FindFirst Method

Thanks for looking at this. I realize how confuse I sound and as a beginner, teaching myself VB 5.0, I am confused and appreciate your help.

I understand Ex 1 from rameses would work fine as long as NameVar does not include quotation marks. My NameVar may or may not contain quotation marks.

Below is my wrong and corrected (hopefully) code where Double_Quote() is a function I wrote which searches for a single quote and pads any single quote found with a single quote. (ie If NameVar = "Bob's" Double_Quote returns "Bob''s")

Wrong Ex2:
rs.FindFirst ("LastName='" & Double_Quote(NameVar) & "'")

Corrected Ex2:
rs.FindFirst "LastName='" & Double_Quote(NameVar) & "'"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close