J
Jaycee
I have three fields in a form that calculate intervals
between various dates. The calculation is achieved via
code (included below) rather than formula. The results
appear correctly in the form, but appear as 0 in the
report. What changes do I need to make to the report to
get the calculated results to appear?
BTW, I'm not a programmer, so please talk slowly and use
small words. Thanks!
___________________
FORM CODE:
Option Compare Database
Private Sub AddNewRecord_Click()
On Error GoTo Err_AddNewRecord_Click
DoCmd.GoToRecord , , acNewRec
Exit_AddNewRecord_Click:
Exit Sub
Err_AddNewRecord_Click:
MsgBox Err.Description
Resume Exit_AddNewRecord_Click
End Sub
Private Sub Date2004_BeforeUpdate(Cancel As Integer)
funIntervalUpdate
End Sub
Private Sub Date2005_BeforeUpdate(Cancel As Integer)
funIntervalUpdate
End Sub
Private Sub Date2006_BeforeUpdate(Cancel As Integer)
funIntervalUpdate
End Sub
Private Sub Form_Current()
funIntervalUpdate
End Sub
Private Sub LastAudit_BeforeUpdate(Cancel As Integer)
funIntervalUpdate
End Sub
Private Function funIntervalUpdate()
'Set 2004 Interval
If Not IsDate(Date2004) Then
Interval2004 = ""
ElseIf Not IsDate(LastAudit) Then
Interval2004 = ""
Else
Interval2004 = DateDiff("m", LastAudit, Date2004)
End If
'Set 2005 Interval
If Not IsDate(Date2005) Then
Interval2005 = ""
ElseIf Not IsDate(Date2004) Then
If Not IsDate(LastAudit) Then
Interval2005 = ""
Else: Interval2005 = DateDiff("m", LastAudit,
Date2005)
End If
Else: Interval2005 = DateDiff("m", Date2004, Date2005)
End If
'Set 2006 Interval
If Not IsDate(Date2006) Then
Interval2006 = ""
ElseIf Not IsDate(Date2005) Then
If Not IsDate(Date2004) Then
If Not IsDate(LastAudit) Then
Interval2006 = ""
Else: Interval2006 = DateDiff("m", LastAudit,
Date2006)
End If
Else: Interval2006 = DateDiff("m", Date2004,
Date2006)
End If
Else: Interval2006 = DateDiff("m", Date2005,
Date2006)
End If
End Function
between various dates. The calculation is achieved via
code (included below) rather than formula. The results
appear correctly in the form, but appear as 0 in the
report. What changes do I need to make to the report to
get the calculated results to appear?
BTW, I'm not a programmer, so please talk slowly and use
small words. Thanks!
___________________
FORM CODE:
Option Compare Database
Private Sub AddNewRecord_Click()
On Error GoTo Err_AddNewRecord_Click
DoCmd.GoToRecord , , acNewRec
Exit_AddNewRecord_Click:
Exit Sub
Err_AddNewRecord_Click:
MsgBox Err.Description
Resume Exit_AddNewRecord_Click
End Sub
Private Sub Date2004_BeforeUpdate(Cancel As Integer)
funIntervalUpdate
End Sub
Private Sub Date2005_BeforeUpdate(Cancel As Integer)
funIntervalUpdate
End Sub
Private Sub Date2006_BeforeUpdate(Cancel As Integer)
funIntervalUpdate
End Sub
Private Sub Form_Current()
funIntervalUpdate
End Sub
Private Sub LastAudit_BeforeUpdate(Cancel As Integer)
funIntervalUpdate
End Sub
Private Function funIntervalUpdate()
'Set 2004 Interval
If Not IsDate(Date2004) Then
Interval2004 = ""
ElseIf Not IsDate(LastAudit) Then
Interval2004 = ""
Else
Interval2004 = DateDiff("m", LastAudit, Date2004)
End If
'Set 2005 Interval
If Not IsDate(Date2005) Then
Interval2005 = ""
ElseIf Not IsDate(Date2004) Then
If Not IsDate(LastAudit) Then
Interval2005 = ""
Else: Interval2005 = DateDiff("m", LastAudit,
Date2005)
End If
Else: Interval2005 = DateDiff("m", Date2004, Date2005)
End If
'Set 2006 Interval
If Not IsDate(Date2006) Then
Interval2006 = ""
ElseIf Not IsDate(Date2005) Then
If Not IsDate(Date2004) Then
If Not IsDate(LastAudit) Then
Interval2006 = ""
Else: Interval2006 = DateDiff("m", LastAudit,
Date2006)
End If
Else: Interval2006 = DateDiff("m", Date2004,
Date2006)
End If
Else: Interval2006 = DateDiff("m", Date2005,
Date2006)
End If
End Function