Discussion Locked

Access 97 SubForms

0 helpful
11 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
When i tab from one subForm to another, how do i prevent Access from saving the Data in the first subForm. When sub1 loses focus, it automatically saves the data in all fields of sub1 to the table it is linked to and i need to find a way to prevent this. If anyone has any ideas please let me know. I have tried putting code in the On_Lost_Focus to send a flag to the Before_Update function and then Cancel the save but all that does is simply Cancel the movement of Focus from one subform to the other. Anyways, any help would be truly appreciated. Thanks.

11 replies

by tonyd

In the both forms make the common field required and also auto save disable this should work

by bowjangles

The common field is the field on the form which is not on either subform. And...where do i set the auto save in Access 97???

by indimulie

Creae a query which will include the fields in the current form and subforms then try working with a recordset from the query which you can update using Code. If you dont want any changes you can use the cdancelupdate method of the recordset.

Hope this sorts out your problem

by it_cowboy

The very nature of Access is to save data once you leave a record. Considering this, you may need to approach it from a different angle...

Add another field to the table under Sub1 called something like 'ToBeSaved' as a Yes/No field. Set the default value to Yes and do not make the field viewable or changeable. This means when a new record is created, the value in this field will be Yes.

When you exit Sub1, the record will be saved, but the 'ToBeSaved' value will be Yes.
Whatever action you want to undo the changes, just run a delete query on the table under Sub1 to remove all records where the 'ToBeSaved' field is Yes.

When you click whatever button to save the record to keep the changes, change the value of this field to No with an Update query.

The only way you can really achieve what you want to do is in code using Begin Trans, Commit and Rollback on the Workspace object.

Hope this helps....

This discussion is closed to new replies.