Now() as a default value

DataMinerHome

Registered User.
Local time
Today, 11:44
Joined
Jan 4, 2010
Messages
57
I have a time field in my table with the default value set to Now(). However, it seems that when I open my table, the value gets set for the next record (even though I haven't started entering it), and if I wait for 10 minutes... or an hour.... to enter the record, the time gets set to that time when I opened the table. This seems pretty undesirable to me!

So, I have a form based on this table, for which I want a time stamp when an entry is made. Again, it seems to set the time stamp as soon as the PREVIOUS record is entered, even though it may be hours until the subsequent record is entered.

I can certainly think of several ways around this, but ....? Is this by design??? Has anyone else noticed this? I would expect the default value to be calculated when I actually start entering the record!

Using access 2010
 
...when I open my table, the value gets set for the next record (even though I haven't started entering it)

I've not got Access 2010, but I don't expect it will be any different to previous incarnations in this instance.

Effectively, there's nothing wrong here. You've set the field to have a default value, so it's showing one. It's just showing the value of the Now() function when you opened the table to view it. If you add a new record, then you should see that record being time-stamped appropriately with the current time rather than what it is initially saying.

If you are time-stamping a record, I would wonder why you would want to show it on screen. Probably because I use time-stamps for behind-the-scenes logging rather than displaying to users. Each to their own, in this respect.
 
Personally, i'd have a completely Unbound form, and then badge the timestamp to the record on Save/Append. This way, you capture an accurate timestamp, as opposed to a timestamp of when the form was opened.

Alternatively, close and re-open the form after each save is completed?
 
Personally, i'd have a completely Unbound form, and then badge the timestamp to the record on Save/Append. This way, you capture an accurate timestamp, as opposed to a timestamp of when the form was opened.
That's a bit inefficient. All that needs to be done is to timestamp the appropriate field in the BeforeUpdate event of the forum, which will trigger when either moving to the next record or closing the form (i.e. leaving the record).
 
I have a time field in my table with the default value set to Now(). However, it seems that when I open my table, the value gets set for the next record (even though I haven't started entering it), and if I wait for 10 minutes... or an hour.... to enter the record, the time gets set to that time when I opened the table. This seems pretty undesirable to me!

So, I have a form based on this table, for which I want a time stamp when an entry is made. Again, it seems to set the time stamp as soon as the PREVIOUS record is entered, even though it may be hours until the subsequent record is entered.

I can certainly think of several ways around this, but ....? Is this by design??? Has anyone else noticed this? I would expect the default value to be calculated when I actually start entering the record!

Using access 2010

it may be that you have some code running when you go to a new record, thsat actually CREATES a new record there and then. If so, the datastamp will be set immediately on record creation.

the best way is probably to do what MileO suggested. Save the value in code.

in the beforeupdate event for the FORM have this

if me.newrecord then
date_stamp_field = now
end if
 
I was using date and time fields in my form and facing same problem of static time but now changed to above solution and is working fine. Thanks.
 

Users who are viewing this thread

Back
Top Bottom