Date Time with a Command Button

  • Thread starter Thread starter Wally S
  • Start date Start date
W

Wally S

Greetings all,
I have an unbound textbox on an unbound form. Two of the
fields are txtDate and txtTime and I put a command button
that is as follows:

Private Sub Command31_Click()
txtDATE = Now()
txtTime = Now()
End Sub

The results I get in both boxes is as follows (which I
know it should be)

10/21/2003 4:41:17 PM

What I need it to do is put the Date as 10/21/2003 and the
Time as 16:41 as this is the way a table that this form
queries is made up. This allows my users to query based
on a date and a time on that date to a date and a time on
another date. I don't want to have the users have to
input 10/20/2003 3:00:00 PM to 10/21/2003 3:00:00 PM to
get entries from that 24 hour period, I want them to be
able to input a begin date in a text box, an end date in a
text box and a begin time in a text box and an end time in
a text box and it will query between those dates.

Any help would be appreciated as I am in Iraq and we have
to do some logging for historical and archival reasons and
don't want to have to pull stuff by hand if I can get
queries to work

Thanks again

Wally S
 
You can use

Me.txtDATE = Format(Date, "mm/dd/yyyy")
Me.txtTime = Format(Time, "hh/nn/ss")

Note that Date() and Time() are also functions that you can use in your code
along with Now().

HTH,

Neil.
 
Back
Top