cannot save the date

  • Thread starter peljo via AccessMonster.com
  • Start date
P

peljo via AccessMonster.com

I am at a loss why i cant save the todays date.On my form i have a control
called LastUpdated.It is set to day/time and to a short date.I want to save
the present date by the following:
Me!LastUpdated = Now
RunCommand acCmdSaveRecord
DoCmd.Close acForm, Me.Name
However the field lastUpdated stays blank and does not show the present date.
What may be the reason ?
 
G

Guest

You don't have a field on a form, you have a control (tables and queries have
fields).

Is your control bound to a field in the form's record source? If not, that
could be the problem.

Also, are you sure you want to use Now()? Now includes the time as well as
the date. Date() only saves the date portion. The difference is if you are
comparing values with dates, you may not get the results you are expecting.

It is not necessary to save the record using RunCommand acCmdSaveRecord
When you move off the record or close the form, the current record is saved.
In fact, the RunCommand should really not be used. It is only supported for
backward compatibility. If you want to save a record programmatically, this
is a better way:

If Me.Dirty Then
Me.Dirty = False
End If
 
J

John W. Vinson

I am at a loss why i cant save the todays date.On my form i have a control
called LastUpdated.It is set to day/time and to a short date.I want to save
the present date by the following:
Me!LastUpdated = Now
RunCommand acCmdSaveRecord
DoCmd.Close acForm, Me.Name
However the field lastUpdated stays blank and does not show the present date.
What may be the reason ?

The reason is probably that a Form is ONLY A WINDOW. Data is not stored in
forms; it's stored in tables, and only in tables. It will not be saved unless
this control is bound to a table date/time field. What's the control's Control
Source?

John W. Vinson [MVP]
 

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