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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving Todays Date? 1

Status
Not open for further replies.

JaeBrett

Programmer
May 5, 2003
196
CN
I have a textbox so when a user inputs a new record I want this box to get filled with todays date (MM/DD/YYYY). How can I do this? And how can I verify if they change it, it's a correct date ???


Thanks.
 
When loading your form, set the content of your textbox to: format$(date, "mm/dd/yyyy").

To validate what they've entered, a textbox isn't the best control to use - use something like the datetime picker that prevents the user from entering bad values.

Chip H.
 
To add it you could use
txtDate.text = Format(Date(),"MM/DD/YY")
(I think the syntax for date formatting is correct, but search help on fromat.. -date is a vb function that returns the current system date, but you could also use Now()

to make sure that the date is correct when they leave
2 options
1
sub txtDate_Validate()
if not isdate(txtdate.text) then
msgbox "this is not a valid date"
txtdate.setfocus
end if
end sub
2. Use the maskededit control
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top