J
Jaycee
I have a form with three unbound controls --
Interval2004, Interval2005, and Interval2006 -- that
calculate the number of months between various dates.
The code for this calculation is included below.
What needs to be done in order for these calculated
values to appear in a report?
Any help is greatly appreciated!
Jaycee
_____________
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
Interval2004, Interval2005, and Interval2006 -- that
calculate the number of months between various dates.
The code for this calculation is included below.
What needs to be done in order for these calculated
values to appear in a report?
Any help is greatly appreciated!
Jaycee
_____________
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