I've been trying to make this "prettier" with a function that runs on load but I'm doing something wrong.
I set a temp table tblLastRefreshDate with a field [RefreshDateTime]
The idea is at each load, delete the temp table, select the first date record in the main table "Forecasts" and set that value as variable LastRefresh then insert that variable back into the temporary table
If I set LastRefresh AS either String or Date, I get the error "Compile Error: Object required with "LastRefresh" highlighted on the "Set" line. If I don't declare the variable as anything, I get a "Type missmatch" error in the last line.
Code:
Private Sub RefreshTime()'save last refresh date
DoCmd.SetWarnings False
Dim LastRefresh
CurrentDb.Execute "DELETE * FROM tblLastRefreshTime"
Set LastRefresh = CurrentDb.OpenRecordset("SELECT First([RefreshDate]) FROM Forecasts")
CurrentDb.Execute "INSERT INTO tblLastRefreshDate(RefreshDateTime) VALUES ('" & LastRefresh & "')"
End Sub