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 ???
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.
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.