Auto enter date/time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to have a feild automatically filled upon entry? I have a
felid "Date" that I would like to auto fill with current date/time when the
form is opened. Is this possible?
 
Set the default value of the field/control to Now().

Note: Naming your field "Date" will only confuse both you and Access. This
is a reserved word in Access.

Regards

<Office/Access MVP>
 
Hi.
Is there a way to have a feild automatically filled upon entry? I have a
felid "Date"

Don't use Reserved words to name identifiers (fields, tables, queries,
forms, variables, et cetera). Date is a Reserved word because it's a VBA
function that will apply the present date to a value if you aren't careful.
(In other words, it could overwrite a previously saved date with today's
date, so you'll never know what the original date was.) I suggest that you
rename your field to something more descriptive, like InvoiceDate.
I would like to auto fill with current date/time when the
form is opened.

In your form's OnOpen( ) event, try:

Private Sub Form_Open(Cancel As Integer)

On Error GoTo ErrHandler

Me!txtInvoiceDate.Value = Now()

Exit Sub

ErrHandler:

MsgBox "Error in Form_Open( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub

.. . . where txtInvoiceDate is the name of the text box displaying today's
date.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 

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

Back
Top