Hi All...
In a form, I have a date field and PostOffice Field. I want the entry to be restricted to one entry daily for every PostOffice.
I tried the code as follows:
Private Sub txtPostOffice_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[txtdate]", "StampsOrderQ", "[Date]= " & [txtDate] & "")) Or Not IsNull(DLookup("[txtpostoffice]", "StampsOrderQ", "[Postoffice]= '" & [txtPostOffice] & "'")) Then
MsgBox "Remember ... Post Office Should Be Entered Once Daily Only", vbCritical
DoCmd.RunCommand acCmdUndo
DoCmd.CancelEvent
DoCmd.SetWarnings False
Exit Sub
End If
DoCmd.SetWarnings True
But it's still accepting the entry of similar office in the same day.
I'm sure something is wrong in my code.
Will anybody check it for me please...
StampsOrderQ is the Query Name and the rest are the names of the fields in the table and form.
Thanks in advance.
In a form, I have a date field and PostOffice Field. I want the entry to be restricted to one entry daily for every PostOffice.
I tried the code as follows:
Private Sub txtPostOffice_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[txtdate]", "StampsOrderQ", "[Date]= " & [txtDate] & "")) Or Not IsNull(DLookup("[txtpostoffice]", "StampsOrderQ", "[Postoffice]= '" & [txtPostOffice] & "'")) Then
MsgBox "Remember ... Post Office Should Be Entered Once Daily Only", vbCritical
DoCmd.RunCommand acCmdUndo
DoCmd.CancelEvent
DoCmd.SetWarnings False
Exit Sub
End If
DoCmd.SetWarnings True
But it's still accepting the entry of similar office in the same day.
I'm sure something is wrong in my code.
Will anybody check it for me please...
StampsOrderQ is the Query Name and the rest are the names of the fields in the table and form.
Thanks in advance.