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

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.
 
J

Jeff Boyce

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
 
S

Stuart McCall

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.
 

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