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!

Automatic Date

Status
Not open for further replies.

Dannybe2

Programmer
Jan 31, 2001
136
GB
I know how to create an automatic date:

In my form, the default date is:

=Date()

The problem is, I want to select a date in a separate field based on the choice made by another field.

When Status = Open - DateField = Blank
When Status = Resolved - DateField = Current Date

I use the following code:

Dim MyDate
MyDate = Date

DateField = MyDate

It looks for a field called Date.

If I use =Now(), It works, but I don't want the time at all.

 
Try:


Format(Now(),"mm/dd/yyyy")


I think that may be what you are looking for.
 
Date is an ambiguous name for a field. It is not good coding to use the words 'Date' or 'Name' as the name of fields in access, as Access uses 'Date' to mean the date, and sometimes defaults to that, even if there is a field named that. The same is with the word 'Name'... Access sometimes uses the name of the object/form/report/database instead of the field you have named that....

What you should do is distinguish the field name in some way.... like 'txtDate' or 'datDate' or some such... The same with the word 'Name'.... I generally use 'txtDate' for any text box that is for the current date... or datDate for any field that is for the current date.

GComyn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top