This is the first time I am trying to call SQL in VBA. I am trying to read the result of the SQL in a recordset.
My Code Looks like this:
I have directly copied SQL from the Query design, with the double quotes added at the start and the end. The code compiles but does not work. The SQL itself is working while called from Access query object. The query selects data from another query ‘queryTestFailu re’ and table ‘MyTests’ (I should have called this ‘tblMytest s’:) ). Reading some articles in the web it seems like I need to modify the SQL string inserting the symbols: doublequotes, ampersand and single quotes. Why do I need to do that, Could I please have some help on it how is done?
Thanks
My Code Looks like this:
Code:
Dim dbs As Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set dbs = CurrentDb
strSQL = "SELECT MyTests.Preconditions FROM QryTestFailure, MyTests WHERE ((([qryTestFailure]![TestID])=[MyTests]![RecNum]));"
Set rs = dbs.OpenRecordset(strSQL, dbOpenDynaset)
NoOfRecords1 = rs.RecordCount
Thanks
Comment