Using Variables as Access Table names

alfboy50
10-25-2004, 11:31 AM
I have a variable called StuChoice and it is coming over from the form before it. The value is coming across so I know it isn't that problem, however I am getting an error that the microsoft jet database engine can't find the 'StuChoice' table. There is a table already created though that holds the value of the variable. I just can't seem to use the variable as a table name though. This is my code and any help would be appreciated. Thanks.
By the way the database and recordset variables are defined properly.

Set Test = DataB.OpenRecordset("Select * from StuChoice where [TestName] = '" & TestChoice & "'")

Shurik12
10-25-2004, 12:28 PM
Dim StuChoice As String
Set Test = DataB.OpenRecordset("Select * from " & StuChoice & " where [TestName] = '" & TestChoice & "'")

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum