Default to prior entry

  • Thread starter Thread starter John Burkard
  • Start date Start date
J

John Burkard

I am using a form to fill in a table and would like to have some of the
entries default to the same value as the previous record. Any suggestions?
 
John said:
I am using a form to fill in a table and would like to have some of the
entries default to the same value as the previous record. Any suggestions?

There may be a better way, but you could put some hidden fields on the form,
such that when a record is saved the following events occur in order.

1. Copy the fields you want to remember to the unbound hidden controls.
2. Save the record.
3. Goto the new record.
4. Set the fields you want to remember to the values you saved.

A drawback to this is that once you set these values, you have initiated a new
record that is not null. This means that when the user closes the form, this
new record will be saved with the defaulted values you have placed into the
record, and possibly nothing else. You can code around this but it isn't easy
(speaking in terms of Access 97 anyway, I can't speak for newer versions).
Part of the solution to this problems is to only allow the user to save the
record via a "Save" button you add to the form, and code the form to always
perform an undo before closing (which is most easily done be adding another
button to close the form). This is the difficult part because it is hard to
keep the user from closing the form by some other means, like closing Access.
If you can train your users to use the buttons you provide and not by some
other method this will work.

gm
 
I am using a form to fill in a table and would like to have some of the
entries default to the same value as the previous record. Any suggestions?

You can put some VBA code in each such control's AfterUpdate event:

Private Sub controlname_AfterUpdate()
Me.controlname.DefaultValue = Chr(34) & Me.controlname & Chr(34)
End Sub

Thus if the user enters XYZ it will set the DefaultValue property to

"XYZ"

which will be used for the next entry.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 

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

Back
Top