How do I set up openrecordset with the table as a variable?

G

GHCORG User

Here is my code:

Dim dbs As Database
Dim rst As Recordset
Dim tbl

tbl = deLblDB1.Caption ' THis is set to "tbINCENC"

Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset(tbl, dbOpenTable)

I receive an error 3011. when I change the tbl variable to:
tbl = "tbINCENC" it works. How do I get the value of the Label in tbl so
this can work?
 
F

FSt1

hi,
Guessing but try this
tbl = Me.deLblDB1.Caption
this would ID the form the caption is on.

Regards
FSt1
 
D

Douglas J Steele

Error 3011 is "The Microsoft Jet database engine could not find the object".
What is deLblDB1? Does the object type that it is have a Caption property?
Has its Caption property been explicitly set? (Many properties don't exist
until they're explicitly created.)
 

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