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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"The Data Has Been Changed..."

Status
Not open for further replies.

Wrangler36

Technical User
Dec 5, 2005
24
0
0
US
I have two forms. Form A is bound to Table X. Form B is bound to Table X and Table Y, but only one field from Table X is ever edited in Form B.

The problem is, once that field that the two forms have in common is edited on Form B and Form B is saved, when I return to Form A (using a back button), I get the message saying that "The Data has changed...re-edit the record".

I made sure to save the changes from Form B before returning to Form A, and I also made sure to do a Refresh of Form A before editing it, but I still get the message.

The message displays in Form A as soon as I begin editing any field. It is only an information message, as it does allow you to continue editing after the message is dimissed, but I need to prevent the message from displaying at all.

Any ideas on how to solve this?
 
Try requerying form A instead of refresh, and this may be why.
The Refresh method shows only changes made to records in the current set. Since the Refresh method doesn't actually requery the database, the current set won't include records that have been added or exclude records that have been deleted since the database was last requeried. Nor will it exclude records that no longer satisfy the criteria of the query or filter. To requery the database, use the Requery method. When the record source for a form is requeried, the current set of records will accurately reflect all data in the record source.
 
Thanks MajP. I tried the Requery method instead of the Refresh method and it does indeed work. I'm not sure why the Refresh method does not work because no records are being added or deleted, the data is only changing and the recordset still meets the query criteria.

I guess I have no choice but to Requery the recordset - unless anyone else out there has any other ideas.

Thanks.

 
How are ya Wrangler36 . . .

[blue]Requery[/blue] is the way to go however it'll always set you back to the first record in formA . . . loosing your current record position there. This may or may not be desirable. To circumvent this try the following in the [blue]AfterUpdate[/blue] event of formB:
Code:
[blue]   Dim frm As Form, hldID
   
   Set frm = Forms![purple][b]NameOfFormA[/b][/purple]
   
   hldID = frm![purple][b]PrimaryKeyNameOfFormA[/b][/purple]
   frm.Requery
   frm.Recordset.FindFirst "[[purple][b]PrimaryKeyNameOfFormA[/b][/purple]]=[red][b]'[/b][/red]" & hldID & "[red][b]'[/b][/red]"

   Set frm = Nothing[/blue]
If the primarykey of FormA is numeric remove the single quotes in [red]red[/red].

[blue]Your thoughts? . . .[/blue]


Calvin.gif
See Ya! . . . . . .
 
You are correct AceMan. When I tried the Requery of Form A, it made the first record the current record, which is not what I want. Saving the primary key before the requery and returning to it after preserves the position of the current record.

I will go ahead and use the Requery method to keep the data in both forms synchronized.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top