Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using 'date()' function - confused with field 3

Status
Not open for further replies.

tobymom

Programmer
Aug 18, 2006
36
US
Dear experts,

on a form A there are
1. txtRegDate (text box)
2. cmdToday (command button)

clicking cmdToday will fill today's date on txtRegDate

cmdToday has this event:
me.txtRegDate = date

Weird thing is this works on some forms and doesn't on other forms. the error msg is
"Run-time error '2465':
Microsoft Access can't find the field 'date' referred to in your expresson."

I was able to fix this problem by rename any field with 'date' name on it. However, this doesn't fix this problem all the time.

Any advice?

Thank you.

 
The following is used in the After Update of a textbox. Forms!frmOdometers!TxtDateStamp.Value = DateSerial(Year(Now()), Month(Now()), Day(Now()))
 




No need for DateSerial...
Code:
 Forms!frmOdometers!TxtDateStamp.Value = Date()

or

 Forms!frmOdometers!TxtDateStamp.Value = Int(Now())


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
The simplest way:
Me!txtRegDate = VBA.Date

Bottom line, avoid to use reserved words.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Dear bubba100, SkipVought and PHV,

Thank you all for your expert advice!

PHV- thank you so much for showing me the simple method. I think it was the way that I was looking for. I thought there's gotta be a way to tell VBA that date is function. You showed me how.

Thank yu all again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top