Jump to content

Using variable to affect later tables


Russian Wyatt 2
Go to solution Solved by David Beagan ,

Recommended Posts

I have a variable (CID) that reads from table a and assigns CID the value from a field (FNum) in table a. and then when I get to table b I want to create a custom field and write the value of CID into table b. What I end up with is not the value of the field from table a, but the name of the field itself (FNum). I'm missing something obvious.

-SET &CID ='Tacos';

DEFINE FILE mini1

-SET &CID = IF FNum EQ ' ' THEN '99-999999' ELSE FNum;

END

TABLE FILE mini1

SUM FNum  

WHERE RECORDLIMIT IS 1

ON TABLE SET BYDISPLAY ON

END

-RUN

DEFINE FILE mini2

Cnum/A10V = '&CID';

UID/A100V = Last_Name || First_Name || Cnum ;

END

TABLE FILE mini2

PRINT UID Last_Name First_Name 

ON TABLE SET BYDISPLAY ON

END

-RUN

if the data in mini1 is 44-444444 and from mini2 is: Last_name: Smith, First_name: John then my output looks like this:

fnumsample.png.0c2828b9719a14cfcd77e1c2a457cd23.png

Link to comment
Share on other sites

  • Solution

DEFINE and -SET don't work together like that. You want to use -READFILE to get the value into a variable. Like this:

TABLE FILE mini1 SUM FNum AS 'CID' WHERE RECORDLIMIT IS 1 ON TABLE SET ASNAME ON ON TABLE HOLD AS FNUMHOLD END-RUN-SET &CID = 'Tacos';-READFILE FNUMHOLD

Then you can continue on with your TABLE FILE MINI2.

The line ON TABLE SET ASNAME ON causes the -READFILE to read into a variable called &CID instead of the default of using the fieldname which would read into a variable called &FNum.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...