DateAdd

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to add one year to a given date and have that populated into
another date field, however the code either does not seem to trigger or is
just not right for some reason ---- help.

One the form there is a date field [dtAuditDate]
A check box for the user to select if a re-audit is to take place.
If the user checks the box I want to be able to programatically add the
re-audit date (which is to take the [dtAuditDate] and add one year to it.

Here is the piece of code that I have been trying to get to work --- what am
I missing here?

Private Sub ckReReview_AfterUpdate()

If Me.ckReAudit = 1 Then
Me.dtReAuditDate.Value = DateAdd("yyyy", 1, Me.dtAuditDate)
End If

End Sub

When debugging, it actually is reading the value of the check box and is
picking up the Audit date, it just doesn't put the date + 1 year into the new
field.
 
Charlie said:
I am trying to add one year to a given date and have that populated
into another date field, however the code either does not seem to
trigger or is just not right for some reason ---- help.

One the form there is a date field [dtAuditDate]
A check box for the user to select if a re-audit is to take place.
If the user checks the box I want to be able to programatically add
the re-audit date (which is to take the [dtAuditDate] and add one
year to it.

Here is the piece of code that I have been trying to get to work ---
what am I missing here?

Private Sub ckReReview_AfterUpdate()

If Me.ckReAudit = 1 Then
Me.dtReAuditDate.Value = DateAdd("yyyy", 1, Me.dtAuditDate)
End If

End Sub

When debugging, it actually is reading the value of the check box and
is picking up the Audit date, it just doesn't put the date + 1 year
into the new field.

True on a CheckBox evaluates to negative one, not positive one.
 
OMG, that was a big DUH! Thank you so much Rick!

Rick Brandt said:
Charlie said:
I am trying to add one year to a given date and have that populated
into another date field, however the code either does not seem to
trigger or is just not right for some reason ---- help.

One the form there is a date field [dtAuditDate]
A check box for the user to select if a re-audit is to take place.
If the user checks the box I want to be able to programatically add
the re-audit date (which is to take the [dtAuditDate] and add one
year to it.

Here is the piece of code that I have been trying to get to work ---
what am I missing here?

Private Sub ckReReview_AfterUpdate()

If Me.ckReAudit = 1 Then
Me.dtReAuditDate.Value = DateAdd("yyyy", 1, Me.dtAuditDate)
End If

End Sub

When debugging, it actually is reading the value of the check box and
is picking up the Audit date, it just doesn't put the date + 1 year
into the new field.

True on a CheckBox evaluates to negative one, not positive one.
 
Back
Top