Question How do I get the short date using now()

vb9063

Registered User.
Local time
Today, 03:02
Joined
Apr 8, 2010
Messages
80
Hi I have used the following code in my form to automatically update a date field when a user enters information or changes info on a form.

Code:
Sub Form_BeforeUpdate(Cancel As Integer)
Me.Sup_Update = Now()
End Sub

However I would like the date to be displayed without the time. Is this possible using datepart() or do I have to use something a bit more complicated??

I would also like to disable the user from being able to put the cursor in the textbox where the date is that will update automatically if this is possible.

Thanks!
Vicky:D
 
If you don't want time at all, use Date() instead of Now(). If you want the time but just want to display date, you can use the format property of the textbox displaying it. To keep the user out, you can use the enabled and/or locked properties of the textbox.
 
Thanks Paul, that worked!
Cheers
vicky
 
No problem Vicky, and welcome to the site!
 
Also
Code:
Me.Sup_Update = Format(Now(),"mm/dd/yyyy")
 
Hi -

If you already have a date which includes time, use the DateValue() function to return just the date (and the TimeValue() function if you need just the time).

Example:

x = now()
? x
5/6/2010 11:40:23 AM

? DateValue(x)
5/6/2010

? TimeValue(x)
11:40:23 AM

HTH - Bob
 

Users who are viewing this thread

Back
Top Bottom