Default date in textbox

J

Jeff

Hi -

I would like to have the date textbox display the current date when a form
is opened. It seems to only work when the DataEntry property is set to Yes
for the form, however I need to have the form open with a record taken from
user input. I have tried several different things and none seem to work.
Thanks for any suggestions.
 
J

Jeff Boyce

Jeff

I'm not sure I'm following...

A form can display controls containing the values in a record. If the form
opens pointed at a specific record, why would THAT record have the current
date in the date control?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Jeff

It's a separate date.

The form is for employee data, and I want to add a part to the form where
the user can enter that a particular employee has been audited. So, I enter
an employee id and the form with that record comes up. Then I want to say
that I audited this employee on 4/1/2009 for example.
This db was already in existence, and I am just adding the auditing part.
All of the data sits in one table. I want to add to each record in the table
Who audited the record and When. And would like the Date to default to the
current so the auditor does not have to enter it.
 
B

banem2

It's a separate date.

The form is for employee data, and I want to add a part to the form where
the user can enter that a particular employee has been audited.  So, I enter
an employee id and the form with that record comes up.  Then I want to say
that I audited this employee on 4/1/2009 for example.
This db was already in existence, and I am just adding the auditing part. 
All of the data sits in one table.  I want to add to each record in thetable
Who audited the record and When.  And would like the Date to default tothe
current so the auditor does not have to enter it.

Hi,

There are two solutions.

1) Make the field defaults to data entered:

Me.datFieldName.DefaultValue = Me.datFieldName

Note that the first date needs to be typed in and each following new
record will display that date, until it is changed.

2) Use BeforeInsert event and run this command:

Me.datFieldName = Date()

Note that current date will appear when the first character has been
typed into new record.

Regards,
Branislav Mihaljev
Microsoft Access MVP
 
K

Ken Sheridan

This has nothing to do with the DefaultValue property; that's solely for when
inserting a new record. Assign the current date to the control bound to the
date field in the AdterUpdate event procedure of another control which will
only be updated when the record is audited, e.g.

Me.[DateAudited] = VBA.Date

Ken Sheridan
Stafford, England
 
J

John W. Vinson

It's a separate date.

The form is for employee data, and I want to add a part to the form where
the user can enter that a particular employee has been audited. So, I enter
an employee id and the form with that record comes up. Then I want to say
that I audited this employee on 4/1/2009 for example.
This db was already in existence, and I am just adding the auditing part.
All of the data sits in one table.

THAT'S your problem.

Does each employee receive one and only one audit for all the time from hire
date to termination date?

Or do you only care about one audit, and you want to permanently erase all
information about prior audits?

I'd really suggest a separate Audits table, with an EmployeeID, an AuditDate
(defaulting to =Date() to capture the date the audit is entered), and fields
for information about the audit (how well did the employee do? who did the
audit? etc.)
I want to add to each record in the table
Who audited the record and When. And would like the Date to default to the
current so the auditor does not have to enter it.

Then you *need a separate table* rather than overwriting data in the Employee
table.

A Default Value applies ONLY when a brand-new record is created ex nihilo.
Editing an existing record, as you are doing, will not cause a Default Value
to be triggered.
 
J

Jeff

Thanks for your help. I'm just an intern trying to add this part. I was
thinking of a separate table myself, but I guess I just didn't think about
the default only applying to a new record. Thanks again
 
B

banem2

Thanks for your help.  I'm just an intern trying to add this part.  Iwas
thinking of a separate table myself, but I guess I just didn't think about
the default only applying to a new record.  Thanks again

Sorry for misunderstanding, but I don't see original post, just your
first reply (Google Groups).

Regards,
Branislav Mihaljev
Microsoft Access MVP
 

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