Whats wrong with this code??

S

SR

Hi,

Can someone please tell me where I am going wrong?
I am trying to learn how to do this so that I can build a more complex
procedure but need the basic blocks.

I have the following simple code in Access 2002 to loop through the
table...............

However, I keep getting an "Run Time error 3001" error on the line "Set rst
= dbs.OpenRecordset(strTable, dbOpenDynamic)"

Thanks
Simon


Sub Test01()

Dim dbs As Database
Dim rst As Recordset
Dim strPath As String
Dim strTable As String

strPath = "P:\Bec2003\Bec2003_be.mdb"
strTable = "tblCLIENT"

Set dbs = OpenDatabase(strPath)
Set rst = dbs.OpenRecordset(strTable, dbOpenDynamic)

Do While Not rst.EOF

Debug.Print rst("RecNo")

Loop

dbs.Close
rst.Close

End Sub
 
S

SR

Thanks for your help here Allen,

I have changed this but am still getting the error " Run Time error 3001 -
Invalid Argument"
on the line " Set rst = dbs.OpenRecordset(strTable, dbOpenDynamic)"

Cheers
Simon
 
A

Allen Browne

dbOpenDynamic applies to ODBC only. Try:
Set rst = dbs.OpenRecordset(strTable, dbOpenDynaset)
 
T

TC

What is dbOpenDynamic? I don't have Access here to check, but from memory it
is normally dbOpenDynaset.

HTH,
TC
 

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