Command button for time & date

  • Thread starter joet5402 via AccessMonster.com
  • Start date
J

joet5402 via AccessMonster.com

I am looking to add START DATE, COMPLETION DATE, START TIME, & FINISH TIME
buttons to an existing form, so that when you press the START DATE button it
would insert the current date into the field; when you press the START TIME -
the current time is inserted and so on.  Is this possible?
 
A

Allen Browne

If you have a text box named START DATE and a command button that should
insert today's date, put this in the Click event procedure of the button:
Me.[START DATE] = Date

To insert the time:
Me.[START TIME] = Time

If you wanted to insert both the date and time into one text box named
StartDateTime:
Me.[StartDateTime] = Now()
 
J

joet5402 via AccessMonster.com

Hi Allen--

I did this with the command buttons, and this message box popped up when I
clicked on the buttons:

"Microsoft Office Access can't find the macro "Me."

The macro (or its macro group) doesn't exist, or the macro is new but
hasn't been saved.

Note that when you enter the macrogroupname.macroname syntax in an
argument, you must specify the name the macro's macro group was last
saved under."

How would I create a macro group (or a macro) for these buttons?

Allen said:
If you have a text box named START DATE and a command button that should
insert today's date, put this in the Click event procedure of the button:
Me.[START DATE] = Date

To insert the time:
Me.[START TIME] = Time

If you wanted to insert both the date and time into one text box named
StartDateTime:
Me.[StartDateTime] = Now()
I am looking to add START DATE, COMPLETION DATE, START TIME, & FINISH TIME
buttons to an existing form, so that when you press the START DATE button
it
would insert the current date into the field; when you press the START
TIME -
the current time is inserted and so on. Is this possible?
 
A

Allen Browne

Set the On Click property of your button to:
[Event Procedure]

Then click the Build button (...) beside this property.
Access opens the code window.
Paste the line between the other 2, e.g.:
Private Sub Command1_Click()
Me.[START DATE] = Date
End Sub

That's what we mean when we talk about the "event procedure" of the button.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

joet5402 via AccessMonster.com said:
Hi Allen--

I did this with the command buttons, and this message box popped up when I
clicked on the buttons:

"Microsoft Office Access can't find the macro "Me."

The macro (or its macro group) doesn't exist, or the macro is new but
hasn't been saved.

Note that when you enter the macrogroupname.macroname syntax in an
argument, you must specify the name the macro's macro group was last
saved under."

How would I create a macro group (or a macro) for these buttons?

Allen said:
If you have a text box named START DATE and a command button that should
insert today's date, put this in the Click event procedure of the button:
Me.[START DATE] = Date

To insert the time:
Me.[START TIME] = Time

If you wanted to insert both the date and time into one text box named
StartDateTime:
Me.[StartDateTime] = Now()
I am looking to add START DATE, COMPLETION DATE, START TIME, & FINISH
TIME
buttons to an existing form, so that when you press the START DATE
button
it
would insert the current date into the field; when you press the START
TIME -
the current time is inserted and so on. Is this possible?
 
J

joet5402 via AccessMonster.com

I've got it to work for START DATE and START TIME, but I haven't got it to
work yet for FINISH TIME and END DATE; I've tried putting those names into
the code, but it is not working. What am I doing wrong?

Allen said:
Set the On Click property of your button to:
[Event Procedure]

Then click the Build button (...) beside this property.
Access opens the code window.
Paste the line between the other 2, e.g.:
Private Sub Command1_Click()
Me.[START DATE] = Date
End Sub

That's what we mean when we talk about the "event procedure" of the button.
Hi Allen--
[quoted text clipped - 31 lines]
 
A

Allen Browne

Keep working on it.

You may need to check the Name property of the text box is what you expect.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

joet5402 via AccessMonster.com said:
I've got it to work for START DATE and START TIME, but I haven't got it to
work yet for FINISH TIME and END DATE; I've tried putting those names into
the code, but it is not working. What am I doing wrong?

Allen said:
Set the On Click property of your button to:
[Event Procedure]

Then click the Build button (...) beside this property.
Access opens the code window.
Paste the line between the other 2, e.g.:
Private Sub Command1_Click()
Me.[START DATE] = Date
End Sub

That's what we mean when we talk about the "event procedure" of the
button.
Hi Allen--
[quoted text clipped - 31 lines]
TIME -
the current time is inserted and so on. Is this possible?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top