Create Auto Date in Subform

T

Tom

I use a subform for tracking notes of phone calls that were placed.

The subform contains a few fields.. for instance, DATE, SUBJECT, NOTES, etc.

When I open the subform for a specific customer, I don't want to enter
"Today's Date" into the Date field.

What's the best way to have the system enter the current date (maybe even
time in another field) once I place the cursor into the Subject field.

I need to make sure that the automatically entered date will be static
(instead of always showing the current system date).

Does anyone know how to do that?
 
A

Allen Browne

1. Open the subform in design view.

2. Right-click the date field, and choose Properties.

3. Set the Default Value property to:
=Date()

Access will drop today's date into the field whenever you create a new
record.

If you wanted the date and time, use:
=Now()

On a side note, "Date" is a reserved word in VBA, so avoid using that as a
field name. (Can be ambiguous in some contexts.)
 
T

Tom

Thanks, Allen..

that works great.

Tom


Allen Browne said:
1. Open the subform in design view.

2. Right-click the date field, and choose Properties.

3. Set the Default Value property to:
=Date()

Access will drop today's date into the field whenever you create a new
record.

If you wanted the date and time, use:
=Now()

On a side note, "Date" is a reserved word in VBA, so avoid using that as a
field name. (Can be ambiguous in some contexts.)
 
A

Allen Browne

Assuming your date/time field is called "UpdatedOn", use the BeforeUpdate
event of the form to assign the current date and time.

The Event Procedure would be:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[UpdatedOn] = Now()
End Sub

If you want just the date (not the time as well), replace "Now()" with
"Date()".
 

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


Top