Need to populate a variable for ExecuteSQL
My first ExecuteSQL with a variable has worked fine, now I need to add some additional queries.
Each of the customers I have need their figures compared to county figures, so really all I need to do is change the SQL query I already and add an 'AND County = '$variable'.
The $variable needs to be the county which the customer resides in and there are 120 or so counties that I am working with, so a variable is needed.
The county details per customer exists on a foreign table to that which I am working on, but is linked by customerID.
How can I ensure that for THIS SQL query, on THIS customer layout it returns the county variable for THIS customer, and then, when I move to the next customer, the query updates because the $variable will change?
Don't think you need a variable here, Just the field specified from the related table--probably using a ? for the optional parameter and then adding a reference to this field as one of the optional paramters.
ExecuteSQL ( "SELECT <rest of query goes here> WHERE county = ? "; "" ; "" ; RelatedTable::County )