Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating data in a subform

Status
Not open for further replies.

randy700

Programmer
Sep 25, 2003
2,384
US
My main form and subform are based on different queries.

The query for the main form returns...
ListID...Product...Location

The query for the subform returns...
ListID...Cost...Quantity...several calculated fields

I can edit data on the main form and on the sub form. However, if I make changes on the main form first, any attempt to make changes on the sub form results in this warning message:
Access said:
The data has changed.
Another user edited this record and saved the changes before you attempted to save your changes.
Re-edit the record.

After clicking the OK button, I can make changes to the subform data without further warnings.

This does not occur if I make changes to the subform first.

How can I stop the warning message from appearing?


Randy
 
Randy,

It sounds like you might want to take a look at your table structure. Typically, if you're using a main form / sub form, you have two tables. The main for is based on the master table, and the subform is based on the second table. The main table has one instace of ListID, and the child table's ListID repeats. You can setup a relationship between the two tables and enforce referential integrity through ListID.

If your two different queries are accessing the same record in the same table, you're going to get a record notice. You can do one of two things:
1. Split the table up into master/child tables or
2. Put a DoCmd.RunCommand acCmdSaveRecord statement in the after update or OnExit property of the last updated control on the main form before the cursor moves to the subform. You can also try the code on the OnEnter property of the subform control (not the properties of the subform itself, but the subform as a control). This will save the record before enterig the subform.

-Patrick

Nine times out of ten, the simplest solution is the best one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top