A
Arpan
I have a MS-Access table wherein two of the columns are named 'Col1' &
'Col2'. Assume that one of the records under the 'Col1' column is 25 &
its corresponding record under the 'Col2' column is 60. Consider the
following query:
PARAMETERS
[ENTER Col1] Short;
SELECT Col2 FROM MyTable WHERE (((MyTable.Col1)=[ENTER Col1]));
As such the above query works fine & when executed, asks the user to
enter a value for 'Col1' & accordingly retrieves the corresponding
'Col2' record. For e.g. if the user enters 25 as the 'Col1' parameter,
then the above query returns 60.
I want to assign the 'Col2' record returned by the query (which is 60
in the above example) to a variable. Depending upon the variable value,
using IF...ELSE conditions, I want to perform different operations.
This is how I have tried to assign the above SELECT statement to a
variable named 'MyVariable':
MyVariable = SELECT Col2 FROM MyTable WHERE (((MyTable.Col1)=[ENTER
Col1]));
But the above throws this error:
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE',
'SELECT' or 'UPDATE'.
Instead of using a variable, I also tried using the SELECT query
directly in a 'IF' condition in this way:
IF (SELECT Col2 FROM MyTable WHERE (((MyTable.Col1)=[ENTER Col1])))
but this too generates the above error.
How do I overcome this error?
'Col2'. Assume that one of the records under the 'Col1' column is 25 &
its corresponding record under the 'Col2' column is 60. Consider the
following query:
PARAMETERS
[ENTER Col1] Short;
SELECT Col2 FROM MyTable WHERE (((MyTable.Col1)=[ENTER Col1]));
As such the above query works fine & when executed, asks the user to
enter a value for 'Col1' & accordingly retrieves the corresponding
'Col2' record. For e.g. if the user enters 25 as the 'Col1' parameter,
then the above query returns 60.
I want to assign the 'Col2' record returned by the query (which is 60
in the above example) to a variable. Depending upon the variable value,
using IF...ELSE conditions, I want to perform different operations.
This is how I have tried to assign the above SELECT statement to a
variable named 'MyVariable':
MyVariable = SELECT Col2 FROM MyTable WHERE (((MyTable.Col1)=[ENTER
Col1]));
But the above throws this error:
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE',
'SELECT' or 'UPDATE'.
Instead of using a variable, I also tried using the SELECT query
directly in a 'IF' condition in this way:
IF (SELECT Col2 FROM MyTable WHERE (((MyTable.Col1)=[ENTER Col1])))
but this too generates the above error.
How do I overcome this error?