How do you insert current date

M

Mark D. Hall

I have a date field setup in a table as a Date/Time data type. When I'm
calling customers, I enter the current date into the form of when I called
and was wondering if there's a way to have Access automatically enter the
current date when I tab to that field. I wouldn't want the field to update
automatically when showing a query or just looking at the customer data but
rather only when I specifically tab to that field. Is this possible? I'm
pretty new to Access and don't know a whole lot of the programming end if
something like that would be required. Thanks.
 
J

James

Hi

For new records you can set the default value in the fields property to
date()

In the On_Enter event for your datefield you could put the following
code to update it to todays date
Me.[datefield].Value = Date()
I would advise against this as you may accidentally update a field with
an existing date by accident just by clicking in it or tabbing to it.

Instead I would advise adding a command button with the above code
instead. You could then click it when you require the date to be
entered.

In the above just replace [datefield] with the name of your date
control. Also, you can use now() instead of date() if you require the
time as well as the date.

James
 
K

kingston via AccessMonster.com

Use the On Got Focus event and the following:

Me.date_control_name = Date
 
G

Guest

Hi Mark

Open the open form and right click the field - select Properties. In the
OnGotFocus event add this code

Private Sub FieldName_GotFocus()
Me.FieldName = Date ()
End Sub
 
M

Mark D. Hall

Thanks for the suggestion. I think I'm figuring out what to do, but I get
an error that Access can't find the macro "Me." Any thoughts?

Mark
--
To reply directly, remove the NOSPAM

James said:
Hi

For new records you can set the default value in the fields property to
date()

In the On_Enter event for your datefield you could put the following
code to update it to todays date
Me.[datefield].Value = Date()
I would advise against this as you may accidentally update a field with
an existing date by accident just by clicking in it or tabbing to it.

Instead I would advise adding a command button with the above code
instead. You could then click it when you require the date to be
entered.

In the above just replace [datefield] with the name of your date
control. Also, you can use now() instead of date() if you require the
time as well as the date.

James


I have a date field setup in a table as a Date/Time data type. When I'm
calling customers, I enter the current date into the form of when I
called
and was wondering if there's a way to have Access automatically enter the
current date when I tab to that field. I wouldn't want the field to
update
automatically when showing a query or just looking at the customer data
but
rather only when I specifically tab to that field. Is this possible?
I'm
pretty new to Access and don't know a whole lot of the programming end if
something like that would be required. Thanks.
 
M

Mark D. Hall

Actually, I think I got it. I was able to figure it out from the three
messages. Are there any books that would explain this stuff? I got an
Access book, published by Microsoft, but it didn't seem to go into details
like this, unless I wasn't looking in the right area. Are these VBA
controls and functions? Thanks for the help.

--
To reply directly, remove the NOSPAM

James said:
Hi

For new records you can set the default value in the fields property to
date()

In the On_Enter event for your datefield you could put the following
code to update it to todays date
Me.[datefield].Value = Date()
I would advise against this as you may accidentally update a field with
an existing date by accident just by clicking in it or tabbing to it.

Instead I would advise adding a command button with the above code
instead. You could then click it when you require the date to be
entered.

In the above just replace [datefield] with the name of your date
control. Also, you can use now() instead of date() if you require the
time as well as the date.

James


I have a date field setup in a table as a Date/Time data type. When I'm
calling customers, I enter the current date into the form of when I
called
and was wondering if there's a way to have Access automatically enter the
current date when I tab to that field. I wouldn't want the field to
update
automatically when showing a query or just looking at the customer data
but
rather only when I specifically tab to that field. Is this possible?
I'm
pretty new to Access and don't know a whole lot of the programming end if
something like that would be required. Thanks.
 

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