Please help me, this one line of code has cost me an entire day already.
I am using a SQL query to open a recordset in the following code:
Private Sub CommandInstructors_Click()
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim IID As DAO.Recordset
Dim ClassNumber As Long
Dim strSQL As String
Dim CurrentRecordID As Long
Set dbs = CurrentDb
Me.ClassID = Me.ComboClassID.Column(0)
ClassNumber = Me.ClassID
strSQL = "SELECT [qryInstr].[ClassID], * " & _
"FROM qryInstr" & _
"WHERE (((qryInstr.[ClassID])= " & _
ClassNumber & "));"
Set IID = dbs.OpenRecordset(strSQL, dbOpenTable)
Every time I try to run it, it keeps giving me an
error 3011, MS Access could not find object SELECT [qryInstr].[ClassID], * FROM qryInstr WHERE (((qryInstr.[ClassID)=1));
I have tried every combination of using brackets, even simplifying the query so I might narrow down what is causing the error, but no luck so far. qryInstr is a SELECT query. I even created a query with everything from strSQL and it works perfect, so I feel completely lost on this. Any help will be greatly appreciated.
:banghead:
Gaatjaat
I am using a SQL query to open a recordset in the following code:
Private Sub CommandInstructors_Click()
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim IID As DAO.Recordset
Dim ClassNumber As Long
Dim strSQL As String
Dim CurrentRecordID As Long
Set dbs = CurrentDb
Me.ClassID = Me.ComboClassID.Column(0)
ClassNumber = Me.ClassID
strSQL = "SELECT [qryInstr].[ClassID], * " & _
"FROM qryInstr" & _
"WHERE (((qryInstr.[ClassID])= " & _
ClassNumber & "));"
Set IID = dbs.OpenRecordset(strSQL, dbOpenTable)
Every time I try to run it, it keeps giving me an
error 3011, MS Access could not find object SELECT [qryInstr].[ClassID], * FROM qryInstr WHERE (((qryInstr.[ClassID)=1));
I have tried every combination of using brackets, even simplifying the query so I might narrow down what is causing the error, but no luck so far. qryInstr is a SELECT query. I even created a query with everything from strSQL and it works perfect, so I feel completely lost on this. Any help will be greatly appreciated.
:banghead:
Gaatjaat