Knowledge Base |

# PRB: BROWSE FIELDS Results Inconsistent in 1-to-Many Relation

Article ID: 117709

Article Last Modified on 12/1/2003

APPLIES TO

- Microsoft Visual FoxPro 3.0 Standard Edition
- Microsoft FoxPro 2.6 Standard Edition
- Microsoft FoxPro 2.6a Standard Edition
- Microsoft FoxPro 2.0
- Microsoft FoxPro 2.6 for MS-DOS
- Microsoft FoxPro 2.6a Standard Edition

This article was previously published under Q117709

## 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 query words: VFoxWin FoxDos FoxWin 2.50 2.50a 2.50b refresh database

Keywords: KB117709