Using Access 2000
On a form, there is a multi-select list box. The Row Source for the list box is...
Behind the Preview button is the following code...
In the ProjectID Group Footer is a control called [txtOwing] for which the Control Source is...
On the OnFormat event for the ProjectID Group Footer is the following code, to display or not display [txtOwing] depending on the DateDiff value...
All of this works fine, no matter how many selections are made in the list box...UNLESS you select <All>. If <All> is selected the code faults out with an Invalid use of Null error on the line
daysTemp = DateDiff("d", [CompletionDateActual], Date)
Any suggestions as to how I fix this would be appreciated.
Thanks.
Tom
On a form, there is a multi-select list box. The Row Source for the list box is...
Code:
SELECT CustomerID,FullName, ProjectNbr, Format(Balance,"currency") AS [Balance Owing], DateDiff("d",[CompletionDateActual],Date()) AS [Days Outstanding] FROM qryBalance WHERE (((qryBalance.Balance)>0)) UNION SELECT "0","<ALL>",'','','' FROM qryBalance
ORDER BY FullName;
Behind the Preview button is the following code...
Code:
Private Sub cmdStatement_Click()
On Error GoTo Err_cmdStatement_Click
Dim ndx As Integer
Dim strList As String
Dim strWHERE As String
Dim stDocName As String
stDocName = "rptStatement"
'Default where-condition is empty
strWHERE = ""
'Test if "<ALL>" is selected
If Me.lstBalance.Selected(0) = False Then
'Loop through items
For ndx = 0 To Me.lstBalance.ListCount - 1
If Me.lstBalance.Selected(ndx) = True Then
strList = strList & Me.lstBalance.ItemData(ndx) & ", "
End If
Next ndx
' Get out if nothing selected
If strList = "" Then
MsgBox "Please select one or more items.", vbExclamation
Me.lstBalance.SetFocus
Exit Sub
End If
strList = Left(strList, Len(strList) - 2)
strWHERE = "[CustomerID] IN (" & strList & ")"
End If
DoCmd.OpenReport stDocName, acPreview, , strWHERE
For ndx = 0 To Me.lstBalance.ListCount - 1
Me.lstBalance.Selected(ndx) = False
Next
Me.txtSelected = Null
Me.Text19 = Null
Exit_cmdStatement_Click:
Exit Sub
Err_cmdStatement_Click:
MsgBox Err.Description
Resume Exit_cmdStatement_Click
End Sub
In the ProjectID Group Footer is a control called [txtOwing] for which the Control Source is...
Code:
="Days since invoiced: " & DateDiff("d",[CompletionDateActual],Date()) & "
Please remit outstanding balance. Thanks!"
On the OnFormat event for the ProjectID Group Footer is the following code, to display or not display [txtOwing] depending on the DateDiff value...
Code:
Private Sub GroupFooter1_Format(Cancel As Integer, FormatCount As Integer)
Dim daysTemp As Integer
daysTemp = DateDiff("d", [CompletionDateActual], Date)
Me.txtOwing.Visible = (daysTemp >= 30)
End Sub
All of this works fine, no matter how many selections are made in the list box...UNLESS you select <All>. If <All> is selected the code faults out with an Invalid use of Null error on the line
daysTemp = DateDiff("d", [CompletionDateActual], Date)
Any suggestions as to how I fix this would be appreciated.
Thanks.
Tom