Totally new to Access VBA. I have the following code... basically I am creating a query called codeNotUsedAt and I just want to open it in a table to see the results.
Code:
Dim qryQuery1 As DAO.QueryDef
Dim qryQuery2 As DAO.QueryDef
Dim qryNotUsedAt As DAO.QueryDef
Set qryQuery1 = dbTrivia.CreateQueryDef("", "SELECT CompletedTrivias.CustomerID, UsedQuestions.QuestionID " _
& "FROM CompletedTrivias RIGHT JOIN UsedQuestions ON CompletedTrivias.ID = UsedQuestions.TriviaID;")
Set qryQuery2 = dbTrivia.CreateQueryDef("", "SELECT Clients.ID, Questions.ID " _
& "FROM Clients, Questions;")
Set qryNotUsedAt = dbTrivia.CreateQueryDef("codeNotUsedAt", "SELECT qryQuery2.Clients.ID, " _
& "qryQuery2.Questions.ID, qryQuery1.QuestionID FROM qryQuery2 LEFT JOIN qryQuery1 ON " _
& "(qryQuery2.Questions.ID = qryQuery1.QuestionID) AND " _
& "(qryQuery2.Clients.ID = qryQuery1.CustomerID) WHERE " _
& "(((qryQuery2.Clients.ID)=" & Me.cboClientName.Value & ") AND " _
& "((qryQuery1.QuestionID) Is Null));")
DoCmd.OpenQuery "codeNotUsedAt"
On the DoCmd.OpenQuery line I get the error code 2001 one saying "You cancelled the previous operation."
Why is this error being thrown? Also I am a bit confused about the difference between qryNotUsedAt and codeNotUsedAt in this code, what's the difference?