Defaults set to first record in continuous form

G

Guest

Many records need almost exactly same data. I would like to enter manually
first record of continous form and have next automatically fill with most of
first record's fields.

Tried setting default of each control to current control ((by Event
Procedure OnChange having Me.DefaultValue = Me.ControlValue) but this carried
over to next usage of form next day. More importantly it would not let the
default to be changed at all!

I'd appreciate any help...
Ruth
 
G

Guest

You are describing the preferred technique for doing this, but you need to be
aware of a few things. First, the Change event is not the correct event.
The Change event should be very seldom used. It fires every time the value
of the control changes. That means every time you enter another character,
it fires. What you want is the After Update event. That only fires when you
move the focus away from the control and only if the value of the control
changed while it had the focus.
To avoid the default value for the current session carrying over to tomorrow
(next session), you need to be sure you do not save changes to the form.
That is done when you close the form:
Instead of
Docmd.Close
Use
Docmd.Close acForm, Me.Name, acSaveNo

The Save option has nothing to do with the data. It only determines whether
changes to the form are saved. A change to the Default Value property of a
control constitutes a change to the form.

I don't know what you mean by "More importantly it would not let the default
to be changed at all!"

The only other issue is whether you want to keep the same default value as
that of the original record or if you want to change the Default value to
match any change made by the user. That you can do with a form level
variable that lets you know whether it is okay to change the Default Value:

At the form level:

Dim blnNotFirstRec As Boolean

In the After Update event:

If Not blnNotFirstRec Then
Me.txtSomeControl.DefaultValue = Me.txtSomeControl
blnNotFirstRec = True
End If
 

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