question about error in code

  • Thread starter Thread starter geert
  • Start date Start date
G

geert

Hello
Guys

I have this beginning in code and on the last line of code I've got
the error 'object required' and it shows me the value of rs2=nothing.
The sql string should return a value, checked by a query. Can someone
help?

Dim sqlstr1 As String
Dim rs2 As Recordset

sqlstr1 = "SELECT Sum(Qry_COFI_bis.SCHULD) AS SumOfSCHULD FROM
Qry_COFI_bis;"

Set rs2 = db1.OpenRecordset(sqlstr1)
 
geert said:
I have this beginning in code and on the last line of code I've got
the error 'object required' and it shows me the value of rs2=nothing.
The sql string should return a value, checked by a query. Can someone
help?

Dim sqlstr1 As String
Dim rs2 As Recordset

sqlstr1 = "SELECT Sum(Qry_COFI_bis.SCHULD) AS SumOfSCHULD FROM
Qry_COFI_bis;"

Set rs2 = db1.OpenRecordset(sqlstr1)


It sounds like db1 is not set.
 
geert said:
Sorry, no db1 is set.


Maybe I could get a clue if you posted the entire
procedure??

Also check your References and make sure that DAO is checked
and ADO is not checked. If those references are something
else, please explain why.
 
I've got something else which doesn't work. Can anybody give some
support?

Error: Object variable not set.
Microsoft DAO library 3.6 selected
__________

Public Sub Command26_Click()
Dim db1 As DAO.Database
Dim rs1 As DAO.Recordset

Set rs1 = db1.OpenRecordset("Qry_cofi_CVMS")



End Sub
 
geert said:
I've got something else which doesn't work. Can anybody give some
support?

Error: Object variable not set.
Microsoft DAO library 3.6 selected
__________

Public Sub Command26_Click()
Dim db1 As DAO.Database
Dim rs1 As DAO.Recordset

Set rs1 = db1.OpenRecordset("Qry_cofi_CVMS")

End Sub

You fogot the line
Set db1 = CurrentDb()
or something like it for the database with the query.
 
Back
Top