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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset.Clone - Type Mismatch

Status
Not open for further replies.

PL01

Technical User
Jun 9, 2008
57
US
I get a type mismatch error when running the recordset.clone code below.

Both INVvar and VNvar are strings, but Invar is a number and VNvar is text

Is the "and" syntax correct for the rs.FindFirst line of code? If I delete everything after "and" I get no mismatch error. (rs.FindFirst "[Inventory #] = " & INVvar)

Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Inventory #] = " & INVvar And "[Vendor Name] = " & VNvar
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
 
rs.FindFirst "[Inventory #] = " & INVvar & " And [Vendor Name] = " & Chr(34) & VNvar & Chr(34)

In INVvar and VNvar are textbox names, then change to Me![INVvar] and Me![VNvar]
 
Dim rs As Object
Set rs = Me.Recordset.Clone

Probably not the issue, but this is a poor declaration of a variable and can cause similar errors. Always be explicit.

me.recordset returns a DAO.recordset
therefore

dim rs as DAO.recordset
and never
dim rs as recordset

this is ambigous since there is a dao.recordset and an aodb.recordset and you will also get similar errors.
 
My preferred way:
Code:
rs.FindFirst "[Inventory #]=" & INVvar & "AND [Vendor Name]='" & Replace(VNvar, "'", "''") & "'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
OOps, sorry for the typo:
Code:
rs.FindFirst "[Inventory #]=" & INVvar & " AND [Vendor Name]='" & Replace(VNvar, "'", "''") & "'"
 
This is all way beyond me but...thank you once again Tek Tips Guy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top