type mistmatch

  • Thread starter Thread starter Guest
  • Start date Start date
The error indicates that Access (or VBA) is trying to treat one type as
another, e.g. Text as a Number, a String as a Date, or an ADO recordset as a
DAO recordset.

In what context do you get this error? In a query? In code that is setting
an object?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 
I have a module where I'm trying to update a field in a recordset. I'm
getting the same error when the first line (set rs=currentdb.openrecordset....
) runs. NOt sure if it's related, but here's my code. Any help would be
appreciated!!


Set Rs = CurrentDb.OpenRecordset("tblUploadConsumersRETFile",
dbOpenForwardOnly)

If Rs.BOF <> True And Rs.EOF <> True Then

Rs.MoveFirst

Do While Rs.EOF <> True

If IsNull(Rs!pesnum) And Not IsNull(Rs!SalesRepCode) Then
Rs!pesnum = strPESNumAvail
End If

Rs.MoveNext

Loop

End If

Rs.Close
Set Rs = Nothing
 
It's the 3rd example.

Above your code you have:
Dim rs As Recordset
The DAO and ADO libraries both have a Recordset object, so you need to
disambiguate. Use:
Dim rs As DAO.Recordset

If you use Access 2000 or 2002, and that line now fails with an "unknown
type" error, you need to set a reference to the DAO library. See:
http://allenbrowne.com/ser-38.html
 
This worked out great!! Thanks so much!!

Wish I had posted this sooner!



Allen said:
It's the 3rd example.

Above your code you have:
Dim rs As Recordset
The DAO and ADO libraries both have a Recordset object, so you need to
disambiguate. Use:
Dim rs As DAO.Recordset

If you use Access 2000 or 2002, and that line now fails with an "unknown
type" error, you need to set a reference to the DAO library. See:
http://allenbrowne.com/ser-38.html
I have a module where I'm trying to update a field in a recordset. I'm
getting the same error when the first line (set
[quoted text clipped - 33 lines]
 
Back
Top