PRB: Form with One-to-Many View Does Not Update Parent Records (130864)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 6.0
- Microsoft Visual FoxPro for Macintosh 3.0b
This article was previously published under Q130864 SYMPTOMS
A form with one-to-many data that is based on a view may not refresh
properly when the data in a parent record changes. The correct data
displays in the record where the data was changed, but other child records
for the parent show the old version of the data. This behavior occurs even
if a TABLEUPDATE() or a ThisForm.Show command is issued.
CAUSE
This is by design. The data in the view is the result of a query that was
performed when the form was initially loaded. The query creates a cursor in
memory with a copy of the data from the source tables. During the form
load, a thermometer bar appears demonstrating the progress of this query.
When a TABLEUPDATE() command is issued, the changes are sent to the source
tables. The child records in the view are not updated because there is no
dynamic link between the view and the source table. These records do not
display the new information until the query is run again.
RESOLUTION
Here are two possible solutions:
- Base the form on the source tables instead of a view. This is
possible only if the view is completely comprised of local tables.
-or-
- Issue a REQUERY() function after each TABLEUPDATE().
Choose the best solution for your situation by weighing the advantages of
using a view with the performance hit caused by the REQUERY() function.
You can place the REQUERY() function in the show or refresh event of the
form. This causes the query to be performed each time a Form.Show or
Form.Refresh is issued, so the most recent data is always displayed.
Alternately, you can place the REQUERY() function in all events that use a
TABLEUPDATE() command, such as the InteractiveChange event of a grid or the
Click event of a command button.
REFERENCES
For more information, please see Chapter 8 of the Microsoft Visual FoxPro
Developer's Guide.
Modification Type: | Major | Last Reviewed: | 12/1/2003 |
---|
Keywords: | KB130864 |
---|
|