Good day Folks,
I have written code in the On Current event of my form as follows:
Dim CurrentDate As Date
Dim NextReviewDate As Date
Dim NewReviewDate As Date
CurrentDate = Me!txtCurrentDate.Value
NextReviewDate = DateAdd("yyyy", 1, Me!txtCurrentDate.Value)
NewReviewDate = NextReviewDate
Me!txtNextReviewDate=NewReviewDate
The above code works fine as I step through each record, but the bit I am struggling with is as follows:
I have a Yes/No check box on my form named txtReviewed (Control source is ysnReviewed)
What I would like to do is when ever this check box is changed to "Yes" is for the value (Date) in the txtNextReviewDate field to replace the value (Date) in the txtCurrentDate and then for the code above to be implemented to produce a new Next Review Date. I'm not sure if this code should still be in the On Current Event of my form either.
I tried the following, but nothing happen on changing the check box:
Dim Reviewed As Boolean
Dim NextNewReviewDate As Date
Reviewed = Me!txtReviewed.value
NextNewReviewDate = Me!txtNextReviewDate
If Reviewed = -1 then
CurrentDate = NextReviewDate ' Replace the Current Date with the Next Review Date
Me!txtCurrentDate.Value = CurrentDate 'Assign the value of CurrentDate as the value of Me!txtCurrentDate
NextReviewDate = DateAdd("yyyy", 1, Me!CurrentDate.Value) 'Calculate a new Next Review Date
Me!txtNextReviewDate.Value = NextReviewDate 'Assign the value of NextReviewDate to the the Me!txtNextReviewDate field
Reviewed = 0 'Assign zero to change the Me!txtReviewed check box to No
Me!txtReviewed.Value = Reviewed 'Assign the value of Reviewed to the value of Me!txtReviewed
End If
So, I've been able to get the first bit of code working, but I'm struggling to workout why this bit of code isn't working, hopefully someone might see what I'm not.
Your assistance is most appreciated.
I have written code in the On Current event of my form as follows:
Dim CurrentDate As Date
Dim NextReviewDate As Date
Dim NewReviewDate As Date
CurrentDate = Me!txtCurrentDate.Value
NextReviewDate = DateAdd("yyyy", 1, Me!txtCurrentDate.Value)
NewReviewDate = NextReviewDate
Me!txtNextReviewDate=NewReviewDate
The above code works fine as I step through each record, but the bit I am struggling with is as follows:
I have a Yes/No check box on my form named txtReviewed (Control source is ysnReviewed)
What I would like to do is when ever this check box is changed to "Yes" is for the value (Date) in the txtNextReviewDate field to replace the value (Date) in the txtCurrentDate and then for the code above to be implemented to produce a new Next Review Date. I'm not sure if this code should still be in the On Current Event of my form either.
I tried the following, but nothing happen on changing the check box:
Dim Reviewed As Boolean
Dim NextNewReviewDate As Date
Reviewed = Me!txtReviewed.value
NextNewReviewDate = Me!txtNextReviewDate
If Reviewed = -1 then
CurrentDate = NextReviewDate ' Replace the Current Date with the Next Review Date
Me!txtCurrentDate.Value = CurrentDate 'Assign the value of CurrentDate as the value of Me!txtCurrentDate
NextReviewDate = DateAdd("yyyy", 1, Me!CurrentDate.Value) 'Calculate a new Next Review Date
Me!txtNextReviewDate.Value = NextReviewDate 'Assign the value of NextReviewDate to the the Me!txtNextReviewDate field
Reviewed = 0 'Assign zero to change the Me!txtReviewed check box to No
Me!txtReviewed.Value = Reviewed 'Assign the value of Reviewed to the value of Me!txtReviewed
End If
So, I've been able to get the first bit of code working, but I'm struggling to workout why this bit of code isn't working, hopefully someone might see what I'm not.
Your assistance is most appreciated.