Preventing future date use

katzi4eva

Registered User.
Local time
Yesterday, 20:07
Joined
Nov 26, 2014
Messages
14
Hi

I have a form for the user to enter new units which arrive in our warehouse, one field in DOM (Date of manufacture) which cannot be a date in the future obviously but could be todays' date. there is table level input mask to make the date 00/00/0000.

i have this code on the form:

Private Sub dom_BeforeUpdate(Cancel As Integer)

If Me.DOM > Date Then
MsgBox "Please enter a Valid DOM", vbInformation, "Check again !!"
Cancel = True
End If
End Sub

which doesn't accept any date whether it's today, last week, last year or in the future!

this is probably very simple but it has had my life!

anyone have any suggestions?

Many Many thanks :)
 
Just to check : what is the field type? It IS Date/Time, isn't it?

If it is, then this should work:

Code:
If Me.DOM.Value > Date Then
  MsgBox "Please enter a Valid DOM", vbInformation, "Check again !!"
  Cancel = True
End If
 
OMG, i knew it was something stupid, it was a text field, i feel so silly right now! Thank you :)
 
it's always the obvious thing that is the most difficult to spot... glad to be of service!
 

Users who are viewing this thread

Back
Top Bottom