I have a question, we have access database, there is date field that is set to automatically display current date. But now they would like to change the date, but if i use the mouse to go to the next field, it showed the date i changed. But if i use the tab key, it will change back to the current date. How can i fix it. It is interesting. Thanks.
One more need to mention, they would like to keep the date that they changed on next record. Is it possible as the date is automatically displayed the current date? They want to keep the date until they need change back the date to be current date.
1) Change the value, press tab and the value changes back.
Sounds like there is something else the matter here. Under normal circumstances, when the value of bound control is changed, once the focus leaves the control, that value is the "new" value for that control (the old value, known as the "dirty value" is also retained). Once the record updates (generally by changing to a different record), all the new values are written and the old values are gone (the record is now "clean").
If pressing the tab key results in the old value being reinstated, then some other process is changing the value back (revert, dirty, undo, locked, after update, before update, etc.)
2) Change the value and have this value become the new default value in subsequent records (presumably for the particular session only).
The easiest way to do this is to put a default value on the control after it is changed - the form's default over-rides the table's default, but the table's default is restored the next time the form is opened.
On your date control, add an After_Update event with code similar to this:
Private Sub txtDate_AfterUpdate()
Me.txtDate.DefaultValue = "#" & Format(Me.txtDate.Value) & "#"