tags:

views:

34

answers:

2

In FoxPro 2.6 for MS-DOS is there a way to use a variable in a SELECT command? For example, how can I write the following query:

SELECT * FROM DBFILE WHERE Ord_no = temp_no

Given that temp_no is a previously defined variable. I tried using "&temp_no" but this does not appear to be the correct syntax.

+1  A: 

Your code looks correct, and you shouldn't need to macro it via the "&". What may be failing is due to data types. If your table "dbfile", column "ord_no" is numeric and your variable "temp_no" is a character string, that would fail due to a data type mismatch... make sure they are the same data type... again, REGARDLESS of using the "&" macro.

MyVarOrd_No = 23

select * from DBFile where Ord_No = MyVarOrd_No

or if a string/charcter based column, just change

MyVarOrd_No = "23"
However you may need to pad with spaces/justify if its being picky.

DRapp
It looks like a blank record was causing the problem. In a blank record the field value would be the null string which cannot be compared to a string. So it was a data type problem.
rsrobbins