gbnorton
asked on
Access 2007 VBA DCount() problem
I'm using this code:
If DCount("[Part_Number]", "Etching_Schedule", "[Part_Number] = 'Me.txtPart_Number'") > 0 Then
MsgBox "That part number already exists for that date and shift."
End If
The code executes without error. That part number does exist and it should go to the message box, but does not.
If I change the > to =, the message box does come up.
I don't understand why it is not finding the matching record.
Thanks,
Brooks
If DCount("[Part_Number]", "Etching_Schedule", "[Part_Number] = 'Me.txtPart_Number'") > 0 Then
MsgBox "That part number already exists for that date and shift."
End If
The code executes without error. That part number does exist and it should go to the message box, but does not.
If I change the > to =, the message box does come up.
I don't understand why it is not finding the matching record.
Thanks,
Brooks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Would you provide an example for the DATE data type?
Thanks,
Brooks
Thanks,
Brooks
If DCount("[Part_Number]", "Etching_Schedule", "[Part_Number] = '" & Me.txtPart_Number &"' And [datefield]=#" & date() & "#") > 0 Then
Me.txtPart_Number must be aoutside the double quotes for it to be evaluated