P
Paul James
I'd like to run a SQL statement which will return a single number, and
assign this number to a variable.
Here's the SQL statement:
"SELECT COUNT(ReceiptID) from tblReceipt WHERE Matched=0"
How do I tell VBA that I want to assign the single-number result of that
SELECT statement to the variable vMatchedCount?
I've tried:
vMatchedCount = "SELECT COUNT(ReceiptID) from tblReceipt WHERE Matched=0"
but that just assigns the entire statement as a text string to the variable.
I tried the same thing without the quotation marks, but that produces the
error "Expected: expression."
There's nothing wrong with the SQL statement itself. I tested it as a query
in the database window and it works fine. I just can't figure out how to
get it to assign the result to a variable in VBA. Could someone please tell
me how do do this?
Thanks in advance,
Paul
assign this number to a variable.
Here's the SQL statement:
"SELECT COUNT(ReceiptID) from tblReceipt WHERE Matched=0"
How do I tell VBA that I want to assign the single-number result of that
SELECT statement to the variable vMatchedCount?
I've tried:
vMatchedCount = "SELECT COUNT(ReceiptID) from tblReceipt WHERE Matched=0"
but that just assigns the entire statement as a text string to the variable.
I tried the same thing without the quotation marks, but that produces the
error "Expected: expression."
There's nothing wrong with the SQL statement itself. I tested it as a query
in the database window and it works fine. I just can't figure out how to
get it to assign the result to a variable in VBA. Could someone please tell
me how do do this?
Thanks in advance,
Paul