Auto populate date in a form

G

Guest

I have a form with a textbox that I need to input today's date each time
someone goes into the textbox. This textbox is tied to a date field in my
table. Can someone please give me suggestions on this.

Thanks.
 
S

sheniece via AccessMonster.com

Hi Chris J.

put the following sub in the gotfocus event of the form the textbox is on,
also change tbxName to the name of your textbox

Private Sub dates_GotFocus()
tbxName.Value = Date
End Sub
 
F

fredg

I have a form with a textbox that I need to input today's date each time
someone goes into the textbox. This textbox is tied to a date field in my
table. Can someone please give me suggestions on this.

Thanks.

Everytime someone enters the text box?

Code it's Enter event:
Me![ControlName] = Date

Of course, this value will change anytime someone tabs into or click
on the control, even days into the future. This doesn't seem logical.
Perhaps you mean something different. If so, give us a bit more
information.
 
G

Guest

No, this works out perfect. I want the date to change each time someone
enters into it. However, I am getting a different date than the current
date. The date I am getting is 12/30/1899 for some reason. Do you have an
idea on what is causing this?

fredg said:
I have a form with a textbox that I need to input today's date each time
someone goes into the textbox. This textbox is tied to a date field in my
table. Can someone please give me suggestions on this.

Thanks.

Everytime someone enters the text box?

Code it's Enter event:
Me![ControlName] = Date

Of course, this value will change anytime someone tabs into or click
on the control, even days into the future. This doesn't seem logical.
Perhaps you mean something different. If so, give us a bit more
information.
 
D

Douglas J. Steele

Access stores dates as 8 byte floating point values where the integer
portion represents the date as the number of days relative to 30 Dec, 1899,
and the decimal portion represents the time as a fraction of a day.

Seeing a date of 12/30/1899 implies that the date is being set to 0.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Chris J. said:
No, this works out perfect. I want the date to change each time someone
enters into it. However, I am getting a different date than the current
date. The date I am getting is 12/30/1899 for some reason. Do you have
an
idea on what is causing this?

fredg said:
I have a form with a textbox that I need to input today's date each
time
someone goes into the textbox. This textbox is tied to a date field in
my
table. Can someone please give me suggestions on this.

Thanks.

Everytime someone enters the text box?

Code it's Enter event:
Me![ControlName] = Date

Of course, this value will change anytime someone tabs into or click
on the control, even days into the future. This doesn't seem logical.
Perhaps you mean something different. If so, give us a bit more
information.
 
G

Guest

So how do I fix this problem?

Douglas J. Steele said:
Access stores dates as 8 byte floating point values where the integer
portion represents the date as the number of days relative to 30 Dec, 1899,
and the decimal portion represents the time as a fraction of a day.

Seeing a date of 12/30/1899 implies that the date is being set to 0.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Chris J. said:
No, this works out perfect. I want the date to change each time someone
enters into it. However, I am getting a different date than the current
date. The date I am getting is 12/30/1899 for some reason. Do you have
an
idea on what is causing this?

fredg said:
On Thu, 15 Nov 2007 06:38:00 -0800, Chris J. wrote:

I have a form with a textbox that I need to input today's date each
time
someone goes into the textbox. This textbox is tied to a date field in
my
table. Can someone please give me suggestions on this.

Thanks.

Everytime someone enters the text box?

Code it's Enter event:
Me![ControlName] = Date

Of course, this value will change anytime someone tabs into or click
on the control, even days into the future. This doesn't seem logical.
Perhaps you mean something different. If so, give us a bit more
information.
 
F

fredg

No, this works out perfect. I want the date to change each time someone
enters into it. However, I am getting a different date than the current
date. The date I am getting is 12/30/1899 for some reason. Do you have an
idea on what is causing this?

fredg said:
I have a form with a textbox that I need to input today's date each time
someone goes into the textbox. This textbox is tied to a date field in my
table. Can someone please give me suggestions on this.

Thanks.

Everytime someone enters the text box?

Code it's Enter event:
Me![ControlName] = Date

Of course, this value will change anytime someone tabs into or click
on the control, even days into the future. This doesn't seem logical.
Perhaps you mean something different. If so, give us a bit more
information.

Where did you place the expression?

On the control's property sheet's Enter event line, write:
[Event Procedure]
Then click on the little button with the 3 dots that appears on that
line.
When the code window opens, the cursor will be flashing between 2
already existing line of code.
Between thos lines writ:
Me![ControlName] = Date

Change [ControlName] to whatever the actual name of that control is
(which may, or may not, be the same as the table field that control
is bound to, i.e. use the Control Name, not the name shown in the
Control Source property).

Exit the code window.
Try it now.

If you still get that 1899 date, place a breakpoint on the code line,
Open the form and tab or click into the date field control.
When the code window appears, hover your cursor over the word Date.
Today's date should appear. Step into the next line. Hover your
cursor over [ControlName]. Today's data should appear. If not, post
back with the exact Enter code you are using and perhaps a bit more
information.
 

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