I have this code which works:
sqlQuery = ("SELECT monthdata.VAL, monthdata.MONTHVAL, monthdata.GREEN, monthdata.RED, monthdata.RAG, monthdata.CREATOR FROM data LEFT JOIN monthdata ON data.UID = monthdata.DATAUID WHERE [UID] = '" & (IDcell) & "' AND [MONTHVAL] = #" & Format((month1), "mm/dd/yyyy") & "#")
I'm specifically interested in the end, i.e this bit:
[MONTHVAL] = #" & Format((month1), "mm/dd/yyyy") & "#")
I now have a variable "month1formatted" which is already in mm/dd/yyyy format. So I tried to put this in as a replacement and lose the formatting bit. This is what I ended up with:
sqlQuery = ("SELECT monthdata.VAL, monthdata.MONTHVAL, monthdata.GREEN, monthdata.RED, monthdata.RAG, monthdata.CREATOR FROM data LEFT JOIN monthdata ON data.UID = monthdata.DATAUID WHERE [UID] = '" & (IDcell) & "' AND [MONTHVAL] = month1formatted"
However, strangley this doesn't work. Am I putting the variable in at the end in the wrong way?
When I print the variable sqlQuery it is printing the text name of the variable (i.e AND [MONTHVAL] = month1formatted)
, not the value of the variable but I know the variable is set correctly