Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table name stored in variable and SELECT statement

Status
Not open for further replies.

Bloosy

Technical User
Jun 23, 2003
15
0
0
Hi everybody
I have a table name stored in a variable. Now is there any way that I can use that variable in SELECT statement.
Example:

Dim rs As Recordset
Dim whichmenu As string
whichmenu = "tablename"
.
.
rsname = "SELECT * FROM whichmenu WHERE field1 ='" &_ something & "'"
Set rs = db.OpenRecordset(rsname, dbOpenDynaset)

The point here is that I don't know the name of the table, it is only for simplicity
 
Just build the the table name into the query like the where clause parameter. Not sure of the purpose of the _ character.

rsname = "SELECT * FROM " & whichmenu & " WHERE field1 ='" & something & "'"
 
Thank you. The _ is from books, meaning that the next line is the same line in your code. Not in right place here
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top