desperateUser
Technical User
I've been scoping out code from previous posts. I'm checking for a duplicate entry on the BeforeUpdate event of a subform. We want to make sure that a payment on a claim hasn't already been made. We're trying to do this by checking for entries in the tblBillAuditDetail table that have a matching payment amount, code mod and date.
When I run this code it gives me
I would like to throw claim number in there but it's on the main form and when I add that to the criteria string
I get run-time error 2001.
Any help is appreciated WAY in advance! Thank you.
Penelope
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim rs As DAO.Recordset, Criteria As String, ID As Long
Dim Msg As String, Style As Integer, Title As String, DL As String, NL As String
NL = vbNewLine
DL = NL & NL
Criteria = "[Payable Amount] = " & Me![Pay Amt] & " And " & _
"[CodeMod] = " & Me![Proc Code] & " AND " & _
"[Date of Service]= #" & Me![Date of Service] & "#"
ID = DLookup("CodeMod", "tblBillAuditDetail", Criteria)
If ID > 0 Then
Msg1 = "A claim payment like this already exists," & DL & _
"check that this isn't a duplicate. Press OK to ignore this message and save the record" & DL & _
Style = vbCritical + vbOKOnly
Title = "Potential record duplicate..."
MsgBox Msg, Style, Title
Me.Undo
Me.Recordset.FindFirst "CodeMod = " & ID
Cancel = True
End If
Set rs = Nothing
End Sub
When I run this code it gives me
Run-time error '3464':
Data type mismatch in criteria expression.
I would like to throw claim number in there but it's on the main form and when I add that to the criteria string
Code:
"[Claim #] = '" & Forms!frmEORHeader.[Claim #] & "' And " & _
I get run-time error 2001.
Any help is appreciated WAY in advance! Thank you.
Penelope