Hi all,
I have tried to research this problem, but am coming up empty. I am getting a runtime error '6': Overflow when I attempt to run this code:
txtEntryNumber is a text field, while txtLineNbr is a numeric field.
tblCDN_ImportsDetail.[Entry Nbr] is linked to tblCDN_ImportsHeader.[Entry Nbr], and I can have multiple, but no duplicates, [Line Nbr].
In the input form, I want to check for a duplicate line item on the BeforeUpdate function, so that the user does not have to input all the other data only to find out that they have a duplicate line.
What am I doing wrong?
I have tried to research this problem, but am coming up empty. I am getting a runtime error '6': Overflow when I attempt to run this code:
Private Sub txtLineNbr_BeforeUpdate(Cancel As Integer)
If DLookup("[txtEntryNumber]", "tblCDN_ImportsDetail", _
"[Entry Nbr] ='" & txtEntryNumber & "'") And _
DLookup("[txtLineNbr]", "tblCDN_ImportsDetail", "[Line Nbr] =" & Me.txtLineNbr) Then
MsgBox "This line number already exists for this entry...", vbExclamation
Cancel = True
Me.Undo
Exit Sub
Else
End If
End Sub
If DLookup("[txtEntryNumber]", "tblCDN_ImportsDetail", _
"[Entry Nbr] ='" & txtEntryNumber & "'") And _
DLookup("[txtLineNbr]", "tblCDN_ImportsDetail", "[Line Nbr] =" & Me.txtLineNbr) Then
MsgBox "This line number already exists for this entry...", vbExclamation
Cancel = True
Me.Undo
Exit Sub
Else
End If
End Sub
txtEntryNumber is a text field, while txtLineNbr is a numeric field.
tblCDN_ImportsDetail.[Entry Nbr] is linked to tblCDN_ImportsHeader.[Entry Nbr], and I can have multiple, but no duplicates, [Line Nbr].
In the input form, I want to check for a duplicate line item on the BeforeUpdate function, so that the user does not have to input all the other data only to find out that they have a duplicate line.
What am I doing wrong?