Date and Time update on new record

A

AlS

My table has two fields, one for Date (Short) and one for Time (Medium) When
I creat a new record in the table the date and time changes correctly. Yet
when I create a new record using a button control in the form, the date and
time do not change?

This form is created directly from the table (no queries) and the fields
are added from the "fields List" dialog box.

Thanks for any light you can shed on this subject,
Al
 
L

Linq Adams via AccessMonster.com

I take it you have the default for these fields set to Now()? You say "the
date and
time do not change?" If the first statement is true, the date isn't going
change until the date actually changes, i.e. any new record entered today
will have today's date; the date won't change until you pass midnight. With a
Medium Time, the time may or may not change if you enter one new record, then
immediately enter a second new record, depending on whether enough time has
passed to put you into the next minute. Maybe this happened when you entered
records in the table and didn't when you entered them in the table.
 
K

Klatuu

First, you should have only one field. Date and Time are held together.
Fields in tables are not formatted. The format property in tables does not
affect how the data is stored, only how it is displayed or printed.
Using one field will save space, take less time, and less coding to control.

To populated one or more fields from a command button (assuming the table is
the form's record source and the fields are bound to controls in the record),
you have to write the code. In the Click Event of the button:

Me.txtDateTime = Now()

If you want the field to be automatically populated when you create a new
record, use =Now() as the Default Value of the control.
 

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