change table name in query

  • Thread starter Thread starter guy
  • Start date Start date
G

guy

i want to create a query below...
every time i run the query, Access pops up a messagebox asking for the
"table_name" from which records are selected...

select * from table_name;

can i do this in Access?

THANKS A LOT!
 
You can do this in a form and some VBA code or a macro. The form would be
your message box. So instead of trying to open a query, you open the form
and enter the table name or select it from a combo box. Use the input
control's After Update event to open the table. HTH.
 
guy said:
i want to create a query below...
every time i run the query, Access pops up a messagebox asking for the
"table_name" from which records are selected...

select * from table_name;

can i do this in Access?


No. Only values will generate a parameter prompt, not
structural items.

You would need to use a VBA procedure to construct the
query's SQL statement. A trivial example might be

Sub UseTable()
Dim strTable As String
Dim strSQL As String

strTable = InputBox("Enter table name")
strSQL = "SELECT * FROM [" & strTable & "]"
'Do something with the query ? ? ?
End Sub

But you must have something more complex than this in mind
or you would just open the table from the database window.
 
i want to create a query below...
every time i run the query, Access pops up a messagebox asking for the
"table_name" from which records are selected...

select * from table_name;

can i do this in Access?

THANKS A LOT!

If your database is set up so that you have multiple
identically-structured tables, and the user needs to enter the table
name... your database is set up *incorrectly*. Could you explain *WHY*
you want to do this? What information is stored in these tables, and
why do you need to prompt for a table name?

John W. Vinson[MVP]
 

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

Back
Top