question about error in code

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)
 
M

Marshall Barton

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.
 
M

Marshall Barton

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.
 
G

geert

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
 
M

Marshall Barton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top