Saving form and subform data at once

J

Jordan

Are there any examples of a form and subform where a user can enter all the
information into the mainform and subform then save all the new and/or
changed data at once.

I have a simple order entry form based on two tables OrderMaster and
OrderDetails where the master table has the Customer, Address, Phone number,
etc and the details has all the items they have purchased (Part, qty, price,
color, etc). My issue with using the easy form/subform link is that after
each item is added to the subform, the previous record changes are
automatically saved. I want to make it so a user can change or add a bunch
of different things on the subform records then decide at the end whether or
not to save the data.
 
G

Guest

Not really any easy way to do this. If the parent record is not in the
recordset, you wont be able to add child records for it in the sub form.
Once you enter the sub form, the record in the main form has already been
saved. Once you move from the current record in the sub form to add a new
one, the one you just entered has been saved.

There are a couple of work arounds I can think of. One, go ahead and allow
the records to be added. Then if the user decides not to keep them, put code
behing a command button to delete the parent and its children. The other
method would be to create a temporary table and base your form on that.
Then when the user decides to save the records, run two append queries - one
for the parent and one for the children. You would also need a delete query
to clear out the temp tables after you have appended its data to the
production table.

I would recommend the first solution.
 
R

Rick Brandt

Jordan said:
Are there any examples of a form and subform where a user can enter
all the information into the mainform and subform then save all the
new and/or changed data at once.

I have a simple order entry form based on two tables OrderMaster and
OrderDetails where the master table has the Customer, Address, Phone
number, etc and the details has all the items they have purchased
(Part, qty, price, color, etc). My issue with using the easy
form/subform link is that after each item is added to the subform,
the previous record changes are automatically saved. I want to make
it so a user can change or add a bunch of different things on the
subform records then decide at the end whether or not to save the
data.

Can't be done in Access unless you bind the forms to "work-tables" and then
use queries upon "saving" that copy the edits to the real tables.

Easier (and better) is to teach your users to use their brains a little bit
before making edits.
 

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