0

As far as I can tell, this strSQL statement is formatted correctly. I've used similar code without any issue in the past. However when I run this, I get a

Run Time Error 3075 - Syntax error (missing operator in query expression 'BucketID=CA.CAD.BAX.0.3.0.CY AND MaxofMarkAsofDate=#8/20/2014#'.

error message. This is frustratingly vague and I can't figure out what the issue is with my strSQL formatting.

  strSQL = "SELECT * FROM FXData WHERE BucketID=" & Forms!Correlation.cboCurve2.Value & " AND MaxOfMarkAsofDate=#" & MaxOfMarkAsofDate & "# ORDER BY MaxOfMarkasOfDate "

Debug.Print strSQL

Set rs = CurrentDb.OpenRecordset(strSQL, Type:=dbOpenDynaset, Options:=dbSeeChanges)
Set rs2 = CurrentDb.OpenRecordset("HolderTable")
2
  • 1
    Include quotes before and after the string value which you compare to BucketID so that piece of your SQL statement looks like this: BucketID='CA.CAD.BAX.0.3.0.CY' Or switch to a parameter query, and you won't need to bother with those quotes or with the # date delimiters. Commented Apr 26, 2016 at 15:09
  • If your first column (usually hidden) is the ID value then use the following: forms!correlation.cboCurve2.column(0) Commented Apr 26, 2016 at 15:14

1 Answer 1

2

This specific part of the error message:

BucketID=CA.CAD.BAX.0.3.0.CY

shows that your BucketID is a string and not a number, you should thus surround it with quotes :

strSQL = "SELECT * FROM FXData WHERE BucketID='" & Forms!Correlation.cboCurve2.Value & "' AND MaxOfMarkAsofDate=#" & MaxOfMarkAsofDate & "# ORDER BY MaxOfMarkasOfDate "
Sign up to request clarification or add additional context in comments.

1 Comment

thanks - I made that change, but now it tells me that :RUN-TIME ERROR '3078': The Microsoft Access database engine cannot find the input table or query 'False'. Make sure it exists and that its name is spelled correctly." I do not call anything by the name of "false" anywhere in this code so I am not sure what this references

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.