PRB: BROWSE FIELDS Results Inconsistent in 1-to-Many Relation
ID: Q117709
2.50x 2.60 2.60a 3.00| 2.00 2.50x 2.60 2.60a
WINDOWS | MS-DOS
kbprg kbprb
The information in this article applies to:
- Microsoft Visual FoxPro for Windows, version 3.0
- Microsoft FoxPro for Windows, versions 2.5x, 2.6, 2.6a
- Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6, 2.6a
SYMPTOMS
The records in the child table of a one-to-many relationship do not update
properly under certain conditions.
RESOLUTION
Issue a GO RECNO() command after returning to the parent table. This forces
FoxPro to refresh the one-to-many relationship, and allows the update of
the BROWSE results.
STATUS
This behavior is by design. FoxPro cannot know what the developer is
attempting to do, and allows the child table data to be read from wherever
the record pointer has moved. By refreshing the relationship between the
two tables with the GO RECNO() command, the developer is given the option
to determine which data should be returned from the child, the old
information or the updated information.
MORE INFORMATION
Steps to Reproduce Behavior
1. Create two physical tables as described below:
PARENT.DBF CHILD.DBF
-----------------------------------------------------------
IDNO(C,5) NAMES(C,10) IDNO(C,5) CITIES(C,10)
111 Sam 114 Fairbanks
112 Mary 113 Houston
113 Beth 115 Phoenix
114 Larry 111 Dover
115 Pat 112 Buffalo
111 Dallas
112 Portland
2. Run the following code in a program. The name of the program does not
matter.
*Open up the tables, and set up the one-to-many relationship
USE Parent IN 1
USE Child IN 2
SELECT Parent
INDEX ON IDNO TAG IDNO
SET ORDER TO IDNO
SELECT Child
INDEX ON IDNO TAG IDNO
SET ORDER TO IDNO
SELECT Parent
SET RELATION TO idno INTO Child
SET SKIP TO Child
SELECT Parent
*Information window, and the first BROWSE FIELDS command displays
*correctly
WAIT WINDOW "Please note how the tables line up appropriately." ;
+CHR(13)+"Hit ESC to continue" NOWAIT
BROWSE FIELDS parent.idno, parent.names, child.idno, child.cities
*Select another record in the child for testing purposes, often a
*SEEK() might be performed here in an actual meaningful program
SELECT child
GO BOTTOM
*Reselect Parent table
SELECT parent
*Information window, and the incorrect results from the BROWSE
*FIELDS command
WAIT WINDOW "Now they don't appear right!!" + CHR(13)+ ;
"Hit ESC to continue" NOWAIT
BROWSE FIELDS parent.idno, parent.names, child.idno, child.cities
*The resolution, an information window, and the corrected results
*from the BROWSE FIELDS command
GO RECNO()
WAIT WINDOW "That fixed it !!" + CHR(13) + "Hit ESC to continue" ;
NOWAIT
BROWSE FIELDS parent.idno, parent.names, child.idno, child.cities
Additional reference words: VFoxWin 3.00 FoxDos FoxWin 2.00 2.50 2.50a
2.50b 2.60
refresh
database
2.60a
KBCategory: kbprg kbprb
KBSubcategory: FxprgBrowse
Keywords : FxprgBrowse
Version : 2.50x 2.60 2.60a 3.00| 2.00 2.50
Platform : MS-DOS WINDOWS