Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for date format

Status
Not open for further replies.

Lhuffst

Programmer
Jun 23, 2003
503
US
How would you check to make sure that a field is formatted correctly? I have a textbox that has a date. The format of the textbox is 'mm/dd/yyyy' and throughout the code it is set up as format(txtdateassigned,"mm/dd/yyyy") but in one instance it is passing the time not the actual date. This is obviously causing problems. How do I code the if statment to make sure that it is a valid date?
Thanks
lhuffst
 
Something like:

Code:
If Not IsDate(txtDateAssigned) Then
    MsgBox "This is not a date."
Else
    'Run your code.
End If

Ed Metcalfe.

Please do not feed the trolls.....
 
Ah, yes. Good point! :)

Time for a rethink....

Ed Metcalfe.

Please do not feed the trolls.....
 
Does this do what you want?

Code:
If Not IsDate(txtDateAssigned) And DateValue(txtDateAssigned)<>"00:00:00" Then
    MsgBox "This is not a date."
Else
    'Run your code.
End If

Ed Metcalfe.

Please do not feed the trolls.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top