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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
hi,
Guessing but try this
tbl = Me.deLblDB1.Caption
this would ID the form the caption is on.

Regards
FSt1
 
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.)
 
Back
Top