Preventing Record Update

G

Guest

Have a main form used for both data entry and viewing details of an existing
record. When a new entry is started, I automatically populate some of the
fields on that form. In the footer of that form is a continuous subform that
shows the records already entered.

Problem: If the user clicks on the subform, the partially complete record
on the main form is added to the table. If they later "cancel" the new
entry, the partially complete record still appears in the table. (Undo
doesn't work.)

I tried using the form's BeforeUpdate to cancel the save unless the "Save"
button was clicked, but that prevents the user from entering the subform, so
they can't use the scroll bar to see the records further down.

Does anyone have a neat solution that will prevent adding the new record but
still allow access to the subform?

Thanks,
Bruce
 
T

tina

no real "easy" solution to the issue. the nature of a form/subform setup is
that any edits to the current record in the main form are automatically
saved when the subform control receives the focus. you can't prevent that.
my only suggestion would be to unbind the controls on the main form. (do NOT
unbind the form itself.) now the data will NOT be saved, until you run
code - from a Save button would be appropriate - that will write the values
in the unbound controls into the corresponding fields in the form's
RecordSource, and save the record.

i've never tried this out, but i think you'll have some issues related to
advancing to a NewRecord in the form, since the controls are not bound to
fields in the form's RecordSource. you'll probably need to write some code
to move to a new record, either automatically or at the user's discretion,
depending on how you need the form to work. make sure you test the form
extensively - if you don't program it correctly, you'll run the risk of the
user accidentally overwriting existing records.

hth
 
G

Guest

Thanks, Tina.

Believe I found an easier solution. I open the data entry form as acDialog.
After it closes, I run a Delete query on the table and remove any invalid
records.

Not real slick, but it works!

Bruce
 

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