Form - Closing

G

Guest

I have a cheque Form, with a Main Frm for all the static data (Date, Cheque
No etc), and linked SubFrms for allocating amounts to different accounts.
Works fine.

If however there is a computer malfunction, or the user inadvertently closes
the Form before the subFrms are completed - then the half-baked data is
saved, resulting in one-sided journal entries (the cardinal sin). I cannot
allow the User to access the 'transaction' table to delete the offending
one-sided entry.

How can I prevent the data being saved if the system is inadvertently closed
down before all entries are completed.
 
A

Allen Browne

Glynn, there is not a simple way to require a user to enter subform entries
whenever they create a record in the main form.

The primary record has to be created (in the main form) before there can be
any related records, so subform records cannot be a requirement for allowing
the primary record to be created. And once you have allowed the main form
record, there is no guarantee that a related record will be entered.

The simplest solution is to just design the database so it works okay for
this scenario, and leave the responsibility with the user. For example, you
might need to use outer-joins in your queries, and watch the way criteria
are handled. Details:
http://allenbrowne.com/casu-02.html
That's all I generally do, and I don't see that this is a cardinal sin.

Another option is to use the AfterInsert event of the main form to create
the related record. Either use AddNew in the subform's RecordsetClone, or
Excute an append query statement to create the first related record.
Although this is not difficult, it does not really solve anything IMHO.

A much more convoluted solution involves entering the records into a temp
table, and writing them to the real table only when related records also
exist. But you also have to handle the editing of records, and prevent the
deletion of all the related records unless the primary record is also being
deleted. Let's just say that attempting to code this to cover all situations
in a multi-user environment is not a trivial task.
 

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