>I'm still a little new to FoxPro, and having issues linking tables together. I have two tables, set up with an appropriate automaticly defined primary key(numerical field, with a default value of "recno()" ), and FoxPro wont let me create any relationship between the two table except a one to one relationship, which is not what i want, and besides that it doesnt work right. I need a one to many relationship. On top of this, FoxPro is working just fine pulling data from the one table, yet will only pull one record from the other(its not updating the form at all), despite the query changing for both tables. Im not sure really how to explain it clearly, but thats the best way to describe it i can come up with. Any suggestions on how to fix this would be welcome
> Brian
The relationship is from index to index.
If you drag a PK index to another PK (or CK) index, you will get a one-to-one relationship.
If you drag a PK index to a regular index, you will get a one-to-many index.
Remember, always drag from the parent to the child.
I agree with Mark, that it is better not to use recno() as the PK.
I am adding my function, which gets a serial number from a table.
HTH,
Hilmar.
FUNCTION SerialNumber(tcSequenceName)
tcSequenceName = upper(tcSequenceName)
local lnOldSelect
lnOldSelect = select()
if used("serialnumber")
select serialnumber
else
select 0
use serialnumber
endif
set order to sequence
if not seek(padr(tcSequenceName, len(sequence)))
append blank
replace sequence with tcSequenceName, nextnum with 1
endif
local lnReturnValue
if lock()
lnReturnValue = nextnum
replace nextnum with nextnum + 1
unlock
else
lnReturnValue = -1
endif
select (lnOldSelect)
return lnReturnValue
ENDFUNC
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)