Now Date Time Field in Form

S

Sarah G

I have a date time field in a form and I need to populate it with the current
date and time when a command button is activated.
If it was a date time at the time that the record is entered I could use the
default property. However I need to populate this field one or two days later
when the follow up phone call is made and the record is re accessed and edited

Thank you
 
R

Rob Parker

Hi Sarah,

In the code for the click event of the command button, in addition to the
other code that you have, put
Me.NameOfDateTimeControl = Now()

This will update the record in the underlying table to the date/time that
the command button is activated.

HTH,

Rob
 
A

Anthos

Me.FieldName.Value = Now()

This VBA Code should do the trick.
Add it to the OnClick event of the button
 
S

Sarah G

that will work as soon as I can work out where in the code to place this.
Sorry. I'm only touch the surface of VBA code.
Me.PREOP_CALL_DATE.Value = Now()
 
J

John W. Vinson

that will work as soon as I can work out where in the code to place this.
Sorry. I'm only touch the surface of VBA code.
Me.PREOP_CALL_DATE.Value = Now()

Open your form in design view. Select the command button that you want to
click to make this happen; view its Properties. On the Events tab select the
Click property; click the ... icon by it, and invoke Code Builder. Access will
give you a Sub and End Sub line - enter this code between them.
 
S

Sarah G

Thank you
I knew how to get into code builder but just needed the last bit. It does
work however when I click on the command it won't insert the date/time until
after I click in the date/time field.
 
J

John W. Vinson

Thank you
I knew how to get into code builder but just needed the last bit. It does
work however when I click on the command it won't insert the date/time until
after I click in the date/time field.

Well... exactly. You put it in the Click event so it works when you Click.

What event do you want? I.e. what form action should cause the field to be
populated?
 

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

Similar Threads

Time Stamp 1
Validation in child form 1
Form Auto Populate 1
Default Value =Date$() in UK Date Format 5
Insert Date/Time Stamp 2
Subforms - Date/Time 2
Need help on auto pop time through a form 2
Date/time edits 2

Top