Data Type Mismatch in criteria

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

I have the below code. It stops on the If DCount line and says Data Type
Mismatch in criteria expression. Run-Time Error '3464':

I can't figure out what is wrong..

Matt

Private Sub LookUpOrder_AfterUpdate()
' Find the record that matches the control.
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset

Set rsc = Me.RecordsetClone


stLinkCriteria = "[LeadsID]='" & Me![LookUpOrder] & "'"


'Check table for for item number.
If DCount("LeadsID", "TblLead97", stLinkCriteria) >= 1 Then
'Go to record of original Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark

'If the item is not found the below code is run.
Else
'Message box warning that part number doesn't exsist.

MsgBox "Order Number" _
& SID & " is not valid order number," _
& vbCr & vbCr & "check the number and try again." _
& vbCr & vbCr & "If the order is still not found" _
& vbCr & vbCr & "contact order entry.", vbExclamation _
, "ORDER NOT FOUND"

End If
Set rsc = Nothing


End Sub
 
G

Guest

Hi Matt,

Is your LeadsID a number? If it is, your line is incorrect, it should be:

stLinkCriteria = "[LeadsID]=" & Me![LookUpOrder]

ie: get rid of the single quotes if LeadsID is a number.

Damian.

mattc66 via AccessMonster.com said:
I have the below code. It stops on the If DCount line and says Data Type
Mismatch in criteria expression. Run-Time Error '3464':

I can't figure out what is wrong..

Matt

Private Sub LookUpOrder_AfterUpdate()
' Find the record that matches the control.
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset

Set rsc = Me.RecordsetClone


stLinkCriteria = "[LeadsID]='" & Me![LookUpOrder] & "'"


'Check table for for item number.
If DCount("LeadsID", "TblLead97", stLinkCriteria) >= 1 Then
'Go to record of original Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark

'If the item is not found the below code is run.
Else
'Message box warning that part number doesn't exsist.

MsgBox "Order Number" _
& SID & " is not valid order number," _
& vbCr & vbCr & "check the number and try again." _
& vbCr & vbCr & "If the order is still not found" _
& vbCr & vbCr & "contact order entry.", vbExclamation _
, "ORDER NOT FOUND"

End If
Set rsc = Nothing


End Sub
 
N

Naeem Azizian

I have the below code. It stops on the If DCount line and says Data Type
Mismatch in criteria expression. Run-Time Error '3464':

I can't figure out what is wrong..

Matt

Private Sub LookUpOrder_AfterUpdate()
' Find the record that matches the control.
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset

Set rsc = Me.RecordsetClone

stLinkCriteria = "[LeadsID]='" & Me![LookUpOrder] & "'"

'Check table for for item number.
If DCount("LeadsID", "TblLead97", stLinkCriteria) >= 1 Then
'Go to record of original Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark

'If the item is not found the below code is run.
Else
'Message box warning that part number doesn't exsist.

MsgBox "Order Number" _
& SID & " is not valid order number," _
& vbCr & vbCr & "check the number and try again." _
& vbCr & vbCr & "If the order is still not found" _
& vbCr & vbCr & "contact order entry.", vbExclamation _
, "ORDER NOT FOUND"

End If
Set rsc = Nothing

End Sub

--
Matt Campbell
mattc (at) saunatec [dot] com

Message posted viahttp://www.accessmonster.com

If the LeadsID is a number then your criteria line shall look like
this:
stLinkCriteria = "( [LeadsID]=" & Me![LookUpOrder] & ")"
 

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