Recordser type mismatch

suzie_q

New member
Local time
Today, 19:57
Joined
Dec 4, 2002
Messages
9
Hello there - why do I get a type mismatch error with the set recs statment in this code?!

Sub manipulateRecords()
Dim recs As Recordset
Dim record As String

Set recs = CurrentDb.OpenRecordset("tableMainData")

While Not recs.EOF
If recs("productType") = "requirements" Then
record = recs(inspectionID)
recs.MoveNext
MsgBox (record)
End If
Wend

End Sub
 
Sub manipulateRecords()
Dim recs As Recordset
Dim record As String

Set recs = CurrentDb.OpenRecordset("tableMainData")

While Not recs.EOF
If recs.Fields("productType") = "requirements" Then
record = recs.Fields("inspectionID")
recs.MoveNext
MsgBox (record)
End If
Wend

End Sub

I think the sub will error if it encounters a "Null" value due to you declaring "Record" as a string ... you may want to cahnge it to a Varaint if the field contains any null values.

HTH
RDH
 
No luck

Thanks for the tip Ricky... Still get the same error though... It gives me runtime error 13 which is a type mismatch... it's definately a problem with the following line of code:

Set recs = CurrentDb.OpenRecordset("tableMainData")

The table tableMainData definately exists so I have no idea what's going on!

Cheers

Suzie
 
You have to define the recordset as DAO:

Dim recs As DAO.Recordset
 

Users who are viewing this thread

Back
Top Bottom