form controlsource in vba

  • Thread starter Thread starter javablood
  • Start date Start date
J

javablood

I have a form in which the rows/columns are the averages and sum (only
precipitation) of weather data. I originally populated the form from a
query but I want the user to be able to select from different tables so I am
using rpt.RecordSpource = MySQL (in which I am able to grab the table name
from a lsitbox). This works with the exception that now the 'search key'
cannot be found because the control source for those columns is now not
correct. Am I able to use the obj.controlsource property? Is so, how?

TIA
 
Here is the SQl I am using

SQL2 = "SELECT [" & tablename & "].[Calendar Date], Round(Avg([" & tablename
& "].WS),2) AS AvgOfWS, " & _
"Round(Avg([" & tablename & "].WD),0) AS AvgOfWD, Round(Avg([" &
tablename & "].sigma),2) AS AvgOfsigma, " & _
"Round(Avg([" & tablename & "].ws_max),2) AS AvgOfws_max, Round(Avg([" &
tablename & "].temp_c),2) " & _
"AS AvgOftemp_c, Round(Avg([" & tablename & "].bar_press),0) AS
AvgOfbar_press, " & _
"Round(Sum([" & tablename & "].rain),2) AS SumOfrain INTO [Temp review
data] FROM [" & tablename & "] " & _
"GROUP BY [" & tablename & "].[Calendar Date] HAVING ((([" & tablename &
"].[Calendar Date]) " & _
"Between [Forms]![Generate Weather Data]![StartDate] " & _
"And [Forms]![Generate Weather Data]![EndDate])) ORDER BY [" & tablename
& "].[Calendar Date];"
 
Back
Top