Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Invalid Subscript Reference Error
Message
From
25/02/2005 14:46:39
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
25/02/2005 12:46:07
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6 SP3
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00990628
Message ID:
00990674
Views:
22
>I've found a workaround, but I'm curious as to what would generate this error.
>
>DIME aFarmType[5]  && policy.fr_type
>aFarmType[1] = 'Field Crop Farms        '
>aFarmType[2] = 'Truck Farms             '
>aFarmType[3] = 'Poultry Farms           '
>aFarmType[4] = 'Livestock Farms         '
>aFarmType[5] = 'Field Crop and Livestock'
>
>SELECT pol.fr_type AS farm_type, loc.state,pol.pol_num;
>  FROM policy pol,location loc;
> WHERE  loc.agentcode=pol.agentcode and loc.ctrl_num=pol.ctrl_num;
>   AND loc.locat_num = 1;
> ORDER BY farm_type,state;
> INTO CURSOR tmp
>
>The code above works just fine. If I
>SELECT DISTINCT farm_type FROM tmp
>I will get values 1,2,3,4,5.
>
SELECT aFarmType[farm_type] FROM tmp
>works just fine. However, when I try to combine all this into one SELECT statement
>
>SELECT aFarmType[pol.fr_type] AS farm_type, loc.state,pol.pol_num;
>  FROM policy pol,location loc;
> WHERE  loc.agentcode=pol.agentcode and loc.ctrl_num=pol.ctrl_num;
>   AND loc.locat_num = 1;
> INTO CURSOR tmp
>
>I get an "Invalid Subscript Reference" error.
>
>As I said, I do have workarounds for this, but I'm curious as to what could cause this behavior.

It seems the old "use first record to measure the field sizes" kicks in here, and in the first record of your table there's a value in farm_type which is not 1...5. While it won't get included in the final recordset, it's still tried out, which gets you the error. Seems to be you'd have to do this in two passes, or just try to have a valid farm_type in the first record.

Another possible workaround here is
on error *

:)

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform