J
javablood
I am trying to use the table name chosen from a list box in an SQL. I know I
am getting the table name from the list box because I can open the table from
the code but I keep getting errors (Form clause, JOIN operation) when trying
to run the SQL. Any ideas? TIA
SQL = "SELECT [Forms]![Generate Weather Data]![Me.tablename].[Calendar
Date], " & _
"Round(Avg([Forms]![Generate Weather Data]![Me.tablename].WS),2) AS
AvgOfWS, " & _
"Round(Avg([Forms]![Generate Weather Data]![Me.tablename].WD),0) AS
AvgOfWD, " & _
"Round(Avg([Forms]![Generate Weather Data]![Me.tablename].sigma),2) AS
AvgOfsigma, " & _
"Round(Avg([Forms]![Generate Weather Data]![Me.tablename].ws_max),2) AS
AvgOfws_max, " & _
"Round(Avg([Forms]![Generate Weather Data]![Me.tablename].temp_c),2) " & _
"AS AvgOftemp_c, Round(Avg([Forms]![Generate Weather
Data]![Me.tablename].bar_press),0) " & _
"AS AvgOfbar_press, Round(Sum([Forms]![Generate Weather
Data]![Me.tablename].rain),2) " & _
"AS SumOfrain INTO [Temp review data] FROM [Forms]![Generate Weather
Data]![Me.tablename] " & _
"GROUP BY [Forms]![Generate Weather Data]![Me.tablename].[Calendar Date]
" & _
"HAVING ((([Forms]![Generate Weather Data]![Me.tablename].[Calendar
Date]) " & _
"Between [Forms]![Generate Weather Data]![StartDate] " & _
"And [Forms]![Generate Weather Data]![EndDate])) " & _
"ORDER BY [Forms]![Generate Weather Data]![Me.tablename].[Calendar Date];"
am getting the table name from the list box because I can open the table from
the code but I keep getting errors (Form clause, JOIN operation) when trying
to run the SQL. Any ideas? TIA
SQL = "SELECT [Forms]![Generate Weather Data]![Me.tablename].[Calendar
Date], " & _
"Round(Avg([Forms]![Generate Weather Data]![Me.tablename].WS),2) AS
AvgOfWS, " & _
"Round(Avg([Forms]![Generate Weather Data]![Me.tablename].WD),0) AS
AvgOfWD, " & _
"Round(Avg([Forms]![Generate Weather Data]![Me.tablename].sigma),2) AS
AvgOfsigma, " & _
"Round(Avg([Forms]![Generate Weather Data]![Me.tablename].ws_max),2) AS
AvgOfws_max, " & _
"Round(Avg([Forms]![Generate Weather Data]![Me.tablename].temp_c),2) " & _
"AS AvgOftemp_c, Round(Avg([Forms]![Generate Weather
Data]![Me.tablename].bar_press),0) " & _
"AS AvgOfbar_press, Round(Sum([Forms]![Generate Weather
Data]![Me.tablename].rain),2) " & _
"AS SumOfrain INTO [Temp review data] FROM [Forms]![Generate Weather
Data]![Me.tablename] " & _
"GROUP BY [Forms]![Generate Weather Data]![Me.tablename].[Calendar Date]
" & _
"HAVING ((([Forms]![Generate Weather Data]![Me.tablename].[Calendar
Date]) " & _
"Between [Forms]![Generate Weather Data]![StartDate] " & _
"And [Forms]![Generate Weather Data]![EndDate])) " & _
"ORDER BY [Forms]![Generate Weather Data]![Me.tablename].[Calendar Date];"