Good morning
I have a landing page in access and am trying to update the "Sub Form_Load" so that when it opens it enters 2 dates in an existing table called Load Dates.
I want to use the dates in this table to run a few other queries so people dont have to keep changing the queries possibly causing errors.
I have written the code below which runs correctly as far as I can tell (when hovering over the dates etc) and it identifies the correct dates, but doesnt align them to the "LoadDates" table.
I have used this format before and it usually will add the data as needed. The "LoadDAtes" table has the fields set up as Date/Time format.
thanks in advance
Gavin
I have a landing page in access and am trying to update the "Sub Form_Load" so that when it opens it enters 2 dates in an existing table called Load Dates.
I want to use the dates in this table to run a few other queries so people dont have to keep changing the queries possibly causing errors.
I have written the code below which runs correctly as far as I can tell (when hovering over the dates etc) and it identifies the correct dates, but doesnt align them to the "LoadDates" table.
I have used this format before and it usually will add the data as needed. The "LoadDAtes" table has the fields set up as Date/Time format.
Code:
Dim dcurrent_day As Date
Dim rst As Recordset
Dim strsql As String
If dcurrent_day = DateAdd("d", 1 - Weekday(Date, vbMonday), Date) Then
DoCmd.RunSQL "Delete LoadDates.* from LoadDates;"
Set rst = CurrentDb.OpenRecordset("LoadDates")
rst.AddNew
rst.Fields("From Date") = Date - 3
rst.Fields("To Date") = Date
Else
DoCmd.RunSQL "Delete LoadDates.* from LoadDates;"
Set rst = CurrentDb.OpenRecordset("LoadDates")
rst.AddNew
rst.Fields("From Date") = Date - 1
rst.Fields("To Date") = Date
End If
thanks in advance
Gavin