Recordset problems

K

Kurt Monroe

I'm new to VBA. I'm trying to open a recordset on a
table, but I get the error "object required" when I run
the code below. The error happens when it executes
the "Set rsCategories..." line.

What am I missing?

Thanks, Kurt


Private Sub Bttn_test_Click()

Dim rsCategories As Recordset
Dim strsql As String

strsql = "Select * from Categories"

Set rsCategories = dbs.OpenRecordset(strsql,
dbOpenSnapshot, dbSQLPassThrough, dbReadOnly)

End Sub
 
C

Chris

Kurt,

You are very close.

Dim dbs as DAO.Database
Dim rst as DAO.Recordset
Dim strSQL as string

strSQL = "Select * from Categories
Set dbs = CurrentDB
Set rst = dbs.openrecordset(strsql)


I realize you're trying to get a forward only, read only
recordset, but I've never used the PassThrough argument.
Try it with no arguments and see how it works.
 

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