Data Type Mismatch Error

G

Guest

I am working on a project and am getting a simple error that has me stumped.
printout and 'may 2008$' are two recordsets/tables in this database. Each has
matching information that I want to compare.The matching information is
ExportID and Export. Both fields are strings (though they are all numeric
characters). ID is a unique identifier beggining with 1 that is in the
printout database but not 'may $2008'. However, I get a "data type mismatch
in criteria expression" referring to the final line in the pasted text. Does
anyone know how to fix this problem, thank you!!

Dim dbMyDB As Database
Set dbMyDB = OpenDatabase("myproject.mdb")

Dim first As Recordset
Set first = dbMyDB.OpenRecordset("printout", dbOpenDynaset)

Dim second As Recordset
Set second = dbMyDB.OpenRecordset("'May 2008'$", dbOpenDynaset)

Dim custID As String
Dim p As Double

p = 1
'later I will loop p to do this for many IDs

first.FindFirst "ID = " & CStr(p)
custID = first!ExportID
second.FindFirst "[Export] = " & custID
 
G

Guest

When you search on a string field, you need to add a single quote before and
after the value, either wise it will treat it as a number, and this is why
you are propmpt with type mismatch

try
first.FindFirst "ID = '" & CStr(p) & "'"
 
G

Guest

When you search on a string field, you need to add a single quote before and
after the value, either wise it will treat it as a number, and this is why
you are propmpt with type mismatch

try
first.FindFirst "ID = '" & CStr(p) & "'"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top