dcount

ssh

Registered User.
Local time
Today, 21:54
Joined
May 22, 2002
Messages
49
How to make the following accept numeric value?

Private Sub Kood_BeforeUpdate(Cancel As Integer)

If DCount("[Kood]", "asukohad", "[Kood]= '" & Me![Kood] & "'") = 1 Then
MsgBox "Already here."
Me.Undo
Cancel = True
End If

End Sub
 
Try:

If Not IsNull (DLookup("[Kood]", "asukohad", "[Kood]= '" & Me![Kood] & "'")) Then
MsgBox "Already here."
Me.Undo
Cancel = True
End If

End Sub
 
Didn't work, still says runtime error 3464: data type mismatch.
 
You could try turning it round:

If IsNull (DLookup("[Kood]", "asukohad", "[Kood]= '" & Me![Kood] & "'")) Then

....
Exit Sub
Else

MsgBox "Already here."
Me.Undo
Cancel = True
End If

End Sub
 
Try using the full reference to the control
DLookUp("FieldName","TableName","([FieldName] = '" & [Forms]![FormName]![FieldName] & "')")
 
Numeric, that's what cause problem.
 
If Not IsNull (DLookup("[Kood]", "asukohad", "[Kood]= " & Me![Kood])) Then
MsgBox "Already here."
Me.Undo
Cancel = True
End If

End Sub
 
Finally! Now accepts numeric. Thank you, DBL!
 

Users who are viewing this thread

Back
Top Bottom