Afterupdate event on a field not working properly

I have a date field on a form and for the afterupdate event I have:

Me.fieldname.defaultvalue = me.fieldname

But then when a new record is entered using the form, which has not been closed, I do not get the value of the previous record in the field. Instead I get12/30/1899 even though the previous record’s value was 3/23/2012.

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you are not using a standard naming convention for your controls, you should be. By default, Access gives bound controls the same name as the field that is their control source, but this can be confusing, so it is highly recommended that you use a naming convention so that when you are programming you can differentiate between controls and fields.

The value #12/30/1899# implies that the default value has not been set, or has been set to 0

You indicate: "But then when a new record is entered using the form, which has not been closed, I do not get the value of the previous record in the field"

When you refer to the "previous record", was the date field in that record actually changed? If not, then the AfterUpdate event would not have fired. If you are just scrolling through records without updating them, then the default value is not getting reset.

You could use the Form_Current event to check to see whether the current record is a new record, and if not, use the current event to set the default value of those controls. Something like:

Private Sub Form_Current

If me.newrecord = false then
me.control1.Defaultvalue = me.control1
me.control2.defaultvalue = me.control2
end if

Another possible solution is to place the name of a User Defined Function in the Default Value property (right on the property sheet). For example, put this in the Default Value property for your control: