this is my vba code assigned to a command button. the sql query works on its own. I get mismatch error when running vba. please help.
Code:
Private Sub Refresh_Click()
Dim rvix As String
Dim db As Database
Set db = CurrentDb
db.Execute "Delete * from historical"
rvix = "insert into historical (macro_var, date_stamp, value_var)" & _
"SELECT a.var_id as macro_var, a.qqy as date_stamp, Max(a.value) AS value_var" & _
"FROM (SELECT var_id, year('var_timestamp') & " / " & datepart('q','var_timestamp') AS qqy, value FROM rrsmtb_t_macro_daily WHERE var_id = 'VIX') AS a" & _
"GROUP BY a.var_id, a.qqy;"
db.execute rvix
Comment