Run-time error '3464': data type mismatch in criteria expression

I am working on updating and improving an old database and changing the table structure, etc.  The data imported well into the new table, but now I want to add the proper "relations" back to the data.  I'm trying to lookup text found in one table in a second table (better said a recordset?) that is also a text field.   I'm getting a data type mismatch error.
    Dim Customers_rst As DAO.Recordset
    Dim ZIP_rst As DAO.Recordset
    Set Customers_rst = CurrentDb.OpenRecordset("Customers", dbOpenDynaset)
    Set ZIP_rst = CurrentDb.OpenRecordset("tblZIPCodes")
        Let strZipToActOn = ZIP_rst.Fields!ZIP
        strSearchData = strZipToActOn
        Customers_rst.FindFirst "CustPostalCode = " & strSearchData
Is there an obvious problem here?
How many points should be assigned to a question like this?
DrftrBobAsked:
Who is Participating?
 
mbizupConnect With a Mentor Commented:
Try this:

    Dim Customers_rst As DAO.Recordset
    Dim ZIP_rst As DAO.Recordset
    Set Customers_rst = CurrentDb.OpenRecordset("Customers", dbOpenDynaset)
    Set ZIP_rst = CurrentDb.OpenRecordset("tblZIPCodes")
         strZipToActOn = ZIP_rst.Fields!ZIP
        strSearchData = strZipToActOn
        Customers_rst.FindFirst "CustPostalCode = '" & strSearchData & "'"

Open in new window

0
 
jerryb30Connect With a Mentor Commented:
Maybe:
Customers_rst.FindFirst "CustPostalCode = '" & strSearchData & "'"
0
 
Jeffrey CoachmanMIS LiasonCommented:
<How many points should be assigned to a question like this? >
Assign points based on the urgency, or perceived difficulty...

Most experts here don't even look at points, they simple answer questions that interest them...
(as you can see here,  you have 3 Experts here within 10 minutes of posting your Q...)

;-)

jeffCoachman
0
 
DrftrBobAuthor Commented:
Thank you.  That answer crossed my mind, but not enough to try it.  I made a new variable for "CustPostalCode = " & strSearchData and it seemed to be quoted properly, so I went back to my original.

I tried crediting both answers, but was unable to figure how (very new here).
0
 
DrftrBobAuthor Commented:
I did that.  Maybe I did split the points.  It seemed to show only the one as the accepted solution.  Thanks for your attention.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.