Date problem

constantG

Registered User.
Local time
Today, 21:29
Joined
Jun 24, 2009
Messages
92
As the title may suggest, I am not looking for friendly advice about going to the cinema, rather a geeky problem with my VBA code. (Maybe I do need the former lol)
Anyway, I have a textbox which holds a date/time using the following format:

Format$(Forms![FRMSIGNAL]![txtDTG], "ddhhnnZ MMM yy") which returns date like this

012359Z JAN 10

The question is how do I feed today's date and the time 10:00 hrs to it via VBA?

Should be simple but I don't understand the syntax.
 
It seems like you getting the date value from a field (txtDTG) on a remote form named FRMSIGNAL, so try this:

Format$(Date(), "ddhhnnZ MMM yy") or

Format$(Now(), "ddhhnnZ MMM yy")
 
It seems like you getting the date value from a field (txtDTG) on a remote form named FRMSIGNAL, so try this:

Format$(Date(), "ddhhnnZ MMM yy") or

Format$(Now(), "ddhhnnZ MMM yy")

To add the time on you would use:
Code:
Dim dteDate As Date
 
dteDate = Date + #10:00:00#

Oh and Freshman - you should stop using the $ in the format, or other functions. That is a holdover from old code which is there just for backwards compatibility. You would just use

Format(...etc.

now.
 
Unless you want it to always show today's date and the fixed time as 10:00 for some reason then use:

=Format$(Now(),"dd""10:00Z """) & Format$(Now(),"mmm yy")
 
Freshman, that's exactly what I want it to do. Perfect.

Thanks
 
PS: Hi Bob, I agree I never use the $ sign but in this case I was simply adapting constantG's original code (he is the one who posed the question).
 
Freshman, Bob, I have changed my code and taken out the $ and it works perfectly.

Thanks
 

Users who are viewing this thread

Back
Top Bottom