Hi Terry,
I haven't read your code in detail, but in general, an indirect
reference to fetch values from a table should _always_ be immidiately
preceeded by a Fetch command.
To fetch values from a table without specifying the row, needs
previously to have set the "active row", and that is what the Fetch
command does.
I.e.
Fetch First From MyTable
n = MyTable.IntVal '-- get value from first (undeleted) row
or
Fetch Rec 23 From MyTable
s = MyTable.SomeStringValue '-- get value from record with rowid = 23
Use Fetch First+Next or Fetch Last+Prev to traverse a table, and use
Fetch Rec to reposition at a record you know exists (or you'll get a run
time error).
Select, Insert and Update may (and may not) set the active row in a
table/query, but never count on it.
Best regards / Med venlig hilsen
Lars Nielsen
GisPro
Terry McDonnell wrote:
Dear List
Please consider the code below. I'm doing the same thing with 3 tables,
to get the description field from the look-up tables, given the FK from
the main table. I've ommitted some of the code but essentially the code
picks up the Zone description (not included here) and the Facility Type
Description (Desc from FacDesc - included), but not the Zone Group
description.
I've put notes and browses in the code to trace what's what but the Zone
Group Description is getting lost somewhere, despite the evidence of my
"break points". This seems really weird - it works fine for the other 2
look-up values. I've annotated, below, (1) - (8), the code where I've
put my traces. It's got me baffled. Any ideas?
'ppreciate it
Terry McDonnell
...
If SelectionInfo( SEL_INFO_NROWS) > 0 then
Insert into csrFacMastPlus
Select * from Selection
lnFacCode = csrFacMastPlus.Fac_Code
lnZone = csrFacMastPlus.Zone
lcZG = csrFacMastPlus.CatchZG '(1) lcZG = "SOUT2" -
OK!
Commit Table csrFacMastPlus
Alter Table csrFacMastPlus ( Add Zone_Desc Char( 40),
FT_Desc Char(
35),
ZG_Desc Char(
50))
Select Desc from FacDesc
where FacDesc.Fac_Code = lnFacCode
into csr1 NoSelect
If SelectionInfo( SEL_INFO_NROWS) > 0 then
Fetch First From csr1
lcDesc = csr1.Desc
Update csrFacMastPlus
Set FT_Desc = lcDesc
End If
...
Select Desc from ZoneGrp
where ZoneGrp.Code = lcZG
into csr1 NoSelect
If SelectionInfo( SEL_INFO_NROWS) > 0 then
Fetch First From csr1
lcDesc = csr1.Desc
Update csrFacMastPlus
Set ZG_Desc = lcDesc
note "lcDesc (ZG) = " + lcDesc
'(2) - gives me "South Suffolk Area Book 2" - OK!
browse * from csrFacMastPlus
'(3) - ZG_Desc shows as (1) above - OK!
End If
Call FAC_DETS_DIALOG
End If ' SelectionInfo()
...
Sub FAC_DETS_DIALOG
' _________________
Dim lcFacName, lcZone, lcFacType, lcZG, lcAdd1, lcAdd2,lcAdd3,
lcAdd4, lcPC, lcXCoord, lcYCoord, lcScaleValue, lcKeyZScore
as String
lcFacName = csrFacMastPlus.Fac_Name
...
lcFacType = RTrim$( STR$( csrFacMastPlus.Fac_Code)) + " - "
+ RTrim$( csrFacMastPlus.FT_Desc)
lcZG = RTrim$( csrFacMastPlus.CatchZG) + " - " +
RTrim$( csrFacMastPlus.ZG_Desc)
browse catchzg, zg_desc from csrFacMastPlus
'(4) Gives "SOUT2" and "South Suffolk Area Book 2" OK
note "csrFacMastPlus.ZG_Desc = " + csrFacMastPlus.ZG_Desc
'(5) but this is BLANK!!!!
note lcZG
'(6) so only "SOUT2 - "
...
DIALOG
Title "Facility Details"
Width 175
Control StaticText
Position 10, 10
Title "Facility:"
Control EditText
Position 60, 10
Width 100
Value lcFacName
...
Control StaticText
Position 10, 94
Title "Type:"
Control EditText
Position 60, 94
Width 100
Value lcFacType '(7) this works fine
...
Control StaticText
Position 10, 118
Title "Catchment ZG:"
Control EditText
Position 60, 118
Width 100
Value lcZG '(8) only "SOUT2 - "
!!!!!!!!!!!!
...
Control OKButton
End Sub
_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l
_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l