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

Run-time Error 13 Type Mismatch 2

Status
Not open for further replies.

3239

Technical User
May 14, 2003
64
I keep getting this error. The code is looking for duplicates in my Autonumber field which is long data type.

What data type do I have to use to get this code to work.

Please Help!!

Thanks.


Code:
Dim lngPOID As Long
    Dim lngLinkCriteria As Long
    Dim rsc As DAO.Recordset

    Set rsc = Me.RecordsetClone

    lngPOID = Me.POID.Value
    lngLinkCriteria = "[POID]=" & "'" & lngPOID & "'"

    'Check Purchase Order table for duplicate Purchase Order Number
    If DCount("POID", "PurchaseOrder", _
              lngLinkCriteria) > 0 Then
        'Undo duplicate entry
        Me.Undo
        'Message box warning of duplication
        MsgBox "Warning Purchase Order Number " _
             & strPOID & " has already been entered." _
             & vbCr & vbCr & "You will now been taken to the record.", _
               vbInformation, "Duplicate Information"
 
change this:
Code:
ngLinkCriteria = "[POID]=" & "'" & lngPOID & "'"

to this:
Code:
ngLinkCriteria = "[POID]=" & lngPOID

Number data types don't need quotes.
 
I eliminated the quotes but I am still getting the error. Any other suggestions?

Thanks.
 
You have the linkcriteria variable declared as a long and you're trying to assign a string to it.

Declare it as a string AND make the change joel suggested and it should work fine.

Hope this helps

HarleyQuinn
---------------------------------
Black coat, white shoes, black hat, cadillac. The boy's a timebomb!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
 
Thanks a lot guys!! It is working now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top