SQL almost complete

cie00011

New member
Local time
Today, 08:06
Joined
Apr 26, 2006
Messages
9
For a graph i have the below code sql to define the chart results

Code:
SELECT [Load],[Displacement] FROM [try];

try is a text box containing a table name within the access DB. how do i change the FROM sql statement to look at the name in the text box and use it as to draw the graph?

options in the text box are for example

TABLE1
TABLE2
etc....

If i use
SELECT [Load],[Displacement] FROM [TABLE1];
SELECT [Load],[Displacement] FROM [TABLE2];

all is well, i need to get it to look at the text box, well a combo box
 
Keep in mind that an SQL statement needs to be a string. To include the evaluation of a variable inside that string, the variable evaluation must occur outside that string.
Code:
Dim tableName As String
Dim sql As String

tableName = "YourTable"
[COLOR="Green"]'this will work[/COLOR]
sql = "SELECT field1, field2 FROM " & tableName & ";"
[COLOR="Green"]'this will fail[/COLOR]
sql = "SELECT field1, field2 FROM tableName;"
 

Users who are viewing this thread

Back
Top Bottom