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

System date entry

Status
Not open for further replies.

Ricky1946

Programmer
Jul 11, 2001
76
GB
Hello,
I have a very annoying problem.
I am trying to populate a text box with the system date by putting coding on a button. But it will not work no matter how hard I try. I would pull my hair out if I had some!
The code I have is on the Click event:
Dim DateToday As Date
DateToday=Date
Forms!CustomerFRM!TxtDate = DateToday.

What is wrong with this?
Regards
Ian

"To say 'thankyou' encourages others."
 
Assuming you are getting no error message, then check (1) that the click event property for the button does contain the entry 'Event Procedure' and (2) that when you click the build button it takes you to this code.
 
Thanks lupins46
I will have a look
Thanks for your prompt reply
Ian

"To say 'thankyou' encourages others."
 
Ian,
Is it safe to assume you don't really have the period after "DateToday."?
Tranman
 
Hello Tranman.
Yes the dot is not in the code. I had to type the code out as it is on another computer. Thanks.

GLackey.
Thanks. Yes the Now function works ok but I have had to format the text box to shield out the time. Even with the text box formatted to date only if the box is clicked it shows the time as well which is not very professional. But it is passable.
Thankyou both for your help.
Inky

"To say 'thankyou' encourages others."
 
Inky,
This will at least get rid of the time stuff:

Private Sub Command2_Click()
Dim DateToday As Date
DateToday = Now()
Forms!myform!txtDate = Format(DateToday, "mm/dd/yyyy")
End Sub

Can't imagine why Date() would not work...

Tranman
 
And this ?
Forms!CustomerFRM!TxtDate = VBA.Date

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Some good suggetions there boys.
Thankyou I will give it a go.
Regards
Inky

"To say 'thankyou' encourages others."
 
PHV,
Thanks it worked a treat!
Ian

"To say 'thankyou' encourages others."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top