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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use a variable for table name in sql code

Status
Not open for further replies.

chainedtodesk

Programmer
Feb 26, 2003
112
US
can you use a variable within the sql query? i have a main db that receives tables from several laptops, i name the files accordingly to the laptop. i want the operator to select a file from a list i provide to update the main table, the table name carries over to portions of the code but does not seem to update the sql.

here is the shortened version of the code

Private Sub Command12_Click()
'DoCmd.SetWarnings False
Dim sql0 As String
Dim F As String
F = Forms!mainform.SelectedTable.Value
sql0 = "INSERT tblAuditsMain_ALL " & _
"SELECT F.* " & _
"FROM F "
DoCmd.RunSQL sql0
End Sub

form is just a list of tables they can select, after update i execute the above code
 
sql0 = "INSERT INTO tblAuditsMain_ALL SELECT * FROM [" & F & "]"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top