M
Mary
I have the following code on the OnClick event of a command button on a Form
to restrict the results of a report.
Private Sub Command24_Click()
Dim strWhere As String
On Error GoTo ErrorHandler
If Not IsNull(Me.Director) Then
strWhere = AddAnd(strWhere)
strWhere = strWhere & "[Director] = '" & Me.Director & "'"
End If
If Not IsNull(Me.ProjectName) Then
strWhere = AddAnd(strWhere)
strWhere = strWhere & "[ProjectName] = '" & Me.ProjectName & "'"
End If
If Not IsNull(Me.Vendor) Then
strWhere = AddAnd(strWhere)
strWhere = strWhere & "[Vendor] = '" & Me.Vendor & "'"
End If
DoCmd.OpenReport "SSExpDtl", acViewPreview, , strWhere
GetOut:
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Number & ": " & _
Err.Description
Resume GetOut
End Select
End Sub
I have added a new combo box to the form to further limit the results based
on a Yes/No field named Active. I'm having trouble getting the desired
results. Where would I add that piece in the code above. I also have the
default value of the Active control set to Yes, and the Format to Yes/No.
BTW - I got that code from this newsgroup and it's been working great.
Thanks!
to restrict the results of a report.
Private Sub Command24_Click()
Dim strWhere As String
On Error GoTo ErrorHandler
If Not IsNull(Me.Director) Then
strWhere = AddAnd(strWhere)
strWhere = strWhere & "[Director] = '" & Me.Director & "'"
End If
If Not IsNull(Me.ProjectName) Then
strWhere = AddAnd(strWhere)
strWhere = strWhere & "[ProjectName] = '" & Me.ProjectName & "'"
End If
If Not IsNull(Me.Vendor) Then
strWhere = AddAnd(strWhere)
strWhere = strWhere & "[Vendor] = '" & Me.Vendor & "'"
End If
DoCmd.OpenReport "SSExpDtl", acViewPreview, , strWhere
GetOut:
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Number & ": " & _
Err.Description
Resume GetOut
End Select
End Sub
I have added a new combo box to the form to further limit the results based
on a Yes/No field named Active. I'm having trouble getting the desired
results. Where would I add that piece in the code above. I also have the
default value of the Active control set to Yes, and the Format to Yes/No.
BTW - I got that code from this newsgroup and it's been working great.
Thanks!