Hi,
At this moment I've got a DCount problem.
I used DCount for several forms and it works fine, but not with a new form.
Problemsituation:
I have a form that uses a query as a recordsource. You are able to fill in a unique number in a text box (txtAfleveringsbonnummer).
I want to check for duplicate numbers so I put the following code behind the textbox:
Private Sub txtAfleveringsbonnummer_BeforeUpdate(Cancel As Integer)
If DCount("[txtAfleveringsbonnummer]", "tblAanvoergegevens", "[Afleveringsbonnummer]='" & Me.txtAfleveringsbonnummer & "'") Then
MsgBox "Number already exists...", vbExclamation
Cancel = True
Me.Undo
Exit Sub
Else
End If
End Sub
I get every time the same error #3464:
"Data type mismatch in criteria expression."
I guess that the way I use DCount for this form is not correct.
Can somebody help me please?!?
Regards,
JiTS
At this moment I've got a DCount problem.
I used DCount for several forms and it works fine, but not with a new form.
Problemsituation:
I have a form that uses a query as a recordsource. You are able to fill in a unique number in a text box (txtAfleveringsbonnummer).
I want to check for duplicate numbers so I put the following code behind the textbox:
Private Sub txtAfleveringsbonnummer_BeforeUpdate(Cancel As Integer)
If DCount("[txtAfleveringsbonnummer]", "tblAanvoergegevens", "[Afleveringsbonnummer]='" & Me.txtAfleveringsbonnummer & "'") Then
MsgBox "Number already exists...", vbExclamation
Cancel = True
Me.Undo
Exit Sub
Else
End If
End Sub
I get every time the same error #3464:
"Data type mismatch in criteria expression."
I guess that the way I use DCount for this form is not correct.
Can somebody help me please?!?
Regards,
JiTS