Solved RunSQL Add a Week, Month, Quarter etc

Malcolm17

Member
Local time
Today, 09:52
Joined
Jun 11, 2018
Messages
109
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
 
Hi. It's really not recommended to store calculated values in tables. Just use a query to calculate the next due date.
 
Okie Dokie, will do. I hadn't really though about that.

Thank you.
 

Users who are viewing this thread

Back
Top Bottom