syntax error

ClaraBarton

Registered User.
Local time
Yesterday, 23:23
Joined
Oct 14, 2019
Messages
623
This is giving me a serious headache
Code:
strWhere = TempVars("DateLimit") And & TempVars("AccountID")

DateLimit is "Year([CkDate]) = " & Year(Date) and AccountID is long (autonumber)

I've tried quotes all over the place and nothing seems to work.
 
You are performing a Boolean operation between a string and an integer.

Tell us the exact string you wanted to see here. I SUSPECT that you want something similar to

Code:
strWhere = TempVars("DateLimit") & " AND " & TempVars("AccountID")

EXCEPT that the result would look like "Year( [CkDate] ) = 2020 AND 431212" - but this is a nonsensical criterion.
 
strwhere, I expect is going to be used in SQL, or at least as a legitimate SQL experession. You need to make sure you construct the criteria with the appropriate column names - perhaps like
strWhere = "Yearcolumnname = " & tempvars("DateLimit") & " AND AccountcolumnIDname = " & tempvars("AccountID")

Use debug.print strwhere in your code after constructing the strwhere string to see what is looks like - a legitimate SQL WHERE string? Also [ ]s may be needed.

using tempvars may be a bit of an overstep, as opposed to using openargs (perhaps), and you will need to be careful of datatype mismatch errors.
 
trWhere = TempVars("DateLimit") & " And " & "TransactionID = " & TempVars("AccountID")
Returns: Year([CkDate]) = 2025 And TransactionID = 47
YESSS!!! Thank you so much!
 

Users who are viewing this thread

Back
Top Bottom