=GenerateWhere() Help

TimE

Registered User.
Local time
Yesterday, 22:37
Joined
May 17, 2005
Messages
55
Form has a list of 5 order types (1 is blank/null) for the user to choose from. I would like to allow the query/report show ALL if nothing is selected (blank/null).

Current code:

Private Sub cmdDetail_Click()
On Error GoTo Err_cmdDetail_Click

Dim stDocName As String

stDocName = "rptAgingReport"
DoCmd.OpenReport stDocName, acPreview, , GenerateWhere()

Exit_cmdDetail_Click:
Exit Sub

Err_cmdDetail_Click:
MsgBox Err.Description
Resume Exit_cmdDetail_Click

End Sub



Private Function GenerateWhere() As String

If Not IsNull(Me.OrderType) And Me.OrderType <> "" Then
GenerateWhere = "[OrderType] = '" & Me.OrderType & "'"
Else
GenerateWhere = ""
End If

End Function


Thanks in advance for ANY help you can provide.
 
I recommend eliminating the Function and combining things:
Code:
Private Sub cmdDetail_Click()
On Error GoTo Err_cmdDetail_Click

Dim stDocName As String

stDocName = "rptAgingReport"

If Len(Me.OrderType & "") > 0 Then
   DoCmd.OpenReport stDocName, acPreview, , "[OrderType] = '" & Me.OrderType & "'"
Else
   DoCmd.OpenReport stDocName, acPreview
End If

Exit_cmdDetail_Click:
Exit Sub

Err_cmdDetail_Click:
MsgBox Err.Description
Resume Exit_cmdDetail_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom