Manage form + subform as a single record

  • Thread starter Thread starter max
  • Start date Start date
M

max

Hi all,
I have a problem that maybe has no solution, but before giving up, I was
wondering if somebody has an idea....
I have a form with a subform (continous) that shows the related records; the
form shows the CDs, while the subform shows a record for each item in the
CD.
Pressing the Edit button, the form and the subform become editable, so that
the user can change the CD details and / or any information about the
content. After having done any change, I've put an undo and a save button so
that the user can decide wheter confirm the changes, or discard them.
As you can image, the save button works anyway (it is almost a fake button
cause access saves automatically) while the undo button often doesn't work,
cause as soon as you click in the subform, the record on the form is saved,
and if the user moves accross several records in the subform and makes
several changes, the undo button will not work for all of them...
Is there a big mistakes somewhere or is it just not possible? Any other
idea?
For us who know what a record and a table are, it is easy to know when to
use save or undo, but for a user that is just doing data entry and doesn't
know anything about Access, would be great to look at form and subform like
a unique record.

Any help or ideas very much appreciated,

Massimo
 
Hi Massimo

This is not a trivial problem. The problem is that you are dealing with
multiple records in multiple tables. Unfortunately, transactions do not
work in bound forms.

I think the best way to solve it (although it seems rather ugly!) is to use
two temporary tables. When the user clicks the Edit button, copy the
current CD record to one temporary table, and copy all the related content
records to the other table. Then change the RecordSources of your form and
subform to bind them to the new tables. Then your Save button can copy the
changed records back again, while the Cancel button simply does nothing,
before switching the RecordSources back to the real tables.
 
when you move from one record to the next, any changes are saved. you can't
stop that from happening unless you Undo the changes first, or cancel the
BeforeUpdate event - which stops you from moving away from the record.
you could do a passive visual cue, such as making the Undo button available
when the current record is Dirty, and graying the button out when it is not.
or you could do an interactive cue by setting a message box on the form's
(and subform's) BeforeUpdate events, asking the user if he/she wants to save
the changes - and handling their response.

hth
 
Hi Graham, Hi Tina, thank you very much for the useful thoughts and tips. I'm working on it ..
Cheers
Massim
 
Back
Top