Once I get this in the most efficient manner, I have at least 90 to do on a similar basis with other dbf library tables.
Ok, I have V9 Platinum Desktop...
I have a form:
On the form is the following:
County Name called DLRCNTY.
County ID called CNTYNO. It is Char as it can be 001..010...290.
These are actual dbf fields in a dbf called DTA.DBF
When the user enters the DLRCNTY value, ex: "HARRIS"
Then the next field is CNTYNO.
I want the CNTYNO filled in by fetching (Looking up) the correct CNTYNO from a "Library" dbf called "county.dbf"
It is indexed by its field called "COUNTY_NAME" and has the value I want in its CNTY_NO field.
Objective:
"on arrival" in the form at CNTYNO, the program does a lookup, using the previous field (DLRCNTY) value.
a lookup would be:
lookup("county.dbf","COUNTY_NAME="+DLRCNTY,"CNTY_NO")
Literal example:
lookup("county.dbf","COUNTY_NAME='HARRIS'","CNTY_NO")
1. How do you set such a lookup default input on a form's dbf field?
In some cases, the user can overwrite it as well, that's why I want it to just default.
Also, I want to switch from getting the CNTYNO from the DLRCNTY, to getting the DLRCNTY from the CNTYNO. I did index the CNTY_NO in the library DBF.
I have done the Lookup formula using the following:
FUNCTION cntylups AS C (sndval AS C,which as c)
DIM RTNFLD AS C
DIM SNDFLDVAL AS C
'------------
if which = "id"
SNDFLDVAL = "COUNTY_NAME = " + S_QUOTE(SNDVAL)
RTNFLD = "CNTY_NO"
elseif which = "name"
SNDFLDVAL = "CNTY_NO = " + S_QUOTE(SNDVAL)
RTNFLD = "COUNTY_NAME"
else
cntylups = "Which?"
exit function
end if
cntylups = alltrim(lookup("COUNTY.DBF",SNDFLDVAL,RTNFLD))
END FUNCTION
Ok, I have V9 Platinum Desktop...
I have a form:
On the form is the following:
County Name called DLRCNTY.
County ID called CNTYNO. It is Char as it can be 001..010...290.
These are actual dbf fields in a dbf called DTA.DBF
When the user enters the DLRCNTY value, ex: "HARRIS"
Then the next field is CNTYNO.
I want the CNTYNO filled in by fetching (Looking up) the correct CNTYNO from a "Library" dbf called "county.dbf"
It is indexed by its field called "COUNTY_NAME" and has the value I want in its CNTY_NO field.
Objective:
"on arrival" in the form at CNTYNO, the program does a lookup, using the previous field (DLRCNTY) value.
a lookup would be:
lookup("county.dbf","COUNTY_NAME="+DLRCNTY,"CNTY_NO")
Literal example:
lookup("county.dbf","COUNTY_NAME='HARRIS'","CNTY_NO")
1. How do you set such a lookup default input on a form's dbf field?
In some cases, the user can overwrite it as well, that's why I want it to just default.
Also, I want to switch from getting the CNTYNO from the DLRCNTY, to getting the DLRCNTY from the CNTYNO. I did index the CNTY_NO in the library DBF.
I have done the Lookup formula using the following:
FUNCTION cntylups AS C (sndval AS C,which as c)
DIM RTNFLD AS C
DIM SNDFLDVAL AS C
'------------
if which = "id"
SNDFLDVAL = "COUNTY_NAME = " + S_QUOTE(SNDVAL)
RTNFLD = "CNTY_NO"
elseif which = "name"
SNDFLDVAL = "CNTY_NO = " + S_QUOTE(SNDVAL)
RTNFLD = "COUNTY_NAME"
else
cntylups = "Which?"
exit function
end if
cntylups = alltrim(lookup("COUNTY.DBF",SNDFLDVAL,RTNFLD))
END FUNCTION
Comment