Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FindFirst Method

Status
Not open for further replies.

bas

Programmer
Jan 13, 1999
41
US
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?
 
&lt;very puzzled look indeed&gt; Could you post an example of what you mean?<br>
<br>
Mike
 
Tell me if this is what you mean:<br>
<br>
Ex. 1. Recordset.FindFirst "LastName='" & NameVar & "'"<br>
Namevar must be a string variable that does not include quotation marks.<br>
<br>
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 &gt; #" & DateVar & "#".<br>
Or you need to simplify your code to make it look like Ex.1 above. <br>
Or maybe we can look at your sample code bec. I have to agree with Mike. <br>
<br>

 
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.<br>
<br>
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. <br>
<br>
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")<br>
<br>
Wrong Ex2:<br>
rs.FindFirst ("LastName='" & Double_Quote(NameVar) & "'")<br>
<br>
Corrected Ex2:<br>
rs.FindFirst "LastName='" & Double_Quote(NameVar) & "'"<br>
<br>
<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top