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?
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 > #" & 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>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.