Solved RunSQL Add a Week, Month, Quarter etc (1 Viewer)

Malcolm17

Member
Local time
Today, 00:00
Joined
Jun 11, 2018
Messages
75
Hello,

I'm trying to update my table with a button on a form after a procedure has run to show the next date due. So it could be Weekly, Monthly, Quarterly etc.

I have used the following which works On Update but not with Run SQL:
If [Frequency] = "Monthly" Then
NextDate = Null
[NextDate] = DateAdd("m", 1, [LastDate])
End If

My code I am trying for weekly is:
Code:
DoCmd.RunSQL "UPDATE HealthSafetyKeyDates SET NextDate = Forms.HealthSafety.txtUpdateDate DateAdd('ww', 1, [Forms.HealthSafety.txtUpdateDate]) WHERE Description = Forms.HealthSafety.cbxFireHeading"

Please can someone show me where I am going wrong with this.

Thank you
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:00
Joined
Oct 29, 2018
Messages
19,134
Hi. It's really not recommended to store calculated values in tables. Just use a query to calculate the next due date.
 

Malcolm17

Member
Local time
Today, 00:00
Joined
Jun 11, 2018
Messages
75
Okie Dokie, will do. I hadn't really though about that.

Thank you.
 

Users who are viewing this thread

Top Bottom