The information in this article applies to:
- Microsoft FoxPro for Windows, versions 2.5 and 2.5a
- Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a
SYMPTOMS
The relationship between two tables (for example, tables named Parent
and Child) appears to be correct when you are browsing the two tables
simultaneously, but in a single Browse window that contains fields
from both tables, the relationship is revealed to be incorrect.
RESOLUTION
For the relationship to work correctly in all cases, you must create
an index in Child that is the same length as the related field in
Parent. For example:
SELECT 2
INDEX ON PADR(num,4) TAG OKNUM
SET ORDER TO OKNUM
SELECT 1
SET RELA TO parent.num INTO child
MORE INFORMATION
Steps to Reproduce Problem
- Create two tables: "Parent", which has a character field named
"Num" with a width of 4, and "Child", which has a character field
named "Num" with a width of 2.
- In Parent, add two records "0 " (zero followed by three spaces)
and "1 " ("1" followed by three spaces).
- In Child, add two records "0 " (zero followed by one space) and "1
" ("1" followed by one space).
- In the Command window, type the following commands:
CLOSE DATABASES
USE parent IN 1
USE child IN 2
SELECT 1
INDEX ON num TAG num
SELECT 2
INDEX ON num TAG num
SELECT 1
SET RELATION TO parent.num INTO child
- Open two Browse windows, one for Parent and one for Child. Note
that when the record pointer in Parent is on either of the two
records in Parent, only the related record appears in the Browse
window for Child.
- Close the two Browse windows, and type the following commands in
the Command window:
SELECT 1
BROWSE FIELDS parent.num, child.num
Note that only the value for the Parent field appears. This behavior
will also occur if a report is built using the relationship between
Parent and Child.
|