Use a variable to set a reference to an Access table object

  • Thread starter Thread starter Zack
  • Start date Start date
Z

Zack

I'm trying to use the 'Application.DoCmd.Outputto acDataTable "Table1", etc.

I have no problem doing it as shown above, but when I try to substitute a
variable for "Table1", I'm not able to do it.

So my question is, how can I save a reference to a table as an object
variable? This seems simple, since table1 is just a table object in table
view of Access. I know its probably a 'Set v = table1' but I'm having a
tough time figuring exact verbage to make the assignment.
 
Zack

"Table1" appears to be a string ... probably the name of a table, and not
the table object itself.

If you want to set a variable equal to the table object, then use it as
you've described, you'll probably need to use the .Name property of that
object.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Zack said:
I'm trying to use the 'Application.DoCmd.Outputto acDataTable "Table1",
etc.

I have no problem doing it as shown above, but when I try to substitute a
variable for "Table1", I'm not able to do it.

So my question is, how can I save a reference to a table as an object
variable? This seems simple, since table1 is just a table object in table
view of Access. I know its probably a 'Set v = table1' but I'm having a
tough time figuring exact verbage to make the assignment.

The OutputTo command expects a string or string variable for this parameter,
so:

Dim TableName As String
TableName = "Table1"
DoCmd.OutputTo acDataTable, TableName etc.

ought to do it. No table object required.
 
Back
Top