73pixieGirl
Programmer
Hello,
I'm not a VB programmer so I'm a bit confused as to what to do. I have an unbound form with 13 combo boxes and 2 text boxes that the user can type in the start date and end date of a specific field. Each combo box's row source is a query that selects distinct values from what's in the table.
I have a button that opens a report (rptHardwareInformation), and the report's record source is a query (qryTest) with fields from the parent and child tables (tblGeneralInfo and tblHardware). The following is some code that's behind the button:
Private Sub cmdPreview_Click()
On Error GoTo Err_cmdPreview_Click
Dim stDocName As String
Dim strFilter As String
stDocName = "rptHardwareInformation"
strFilter = "1=1 "
If Not IsNull(Me!cboAPL.Value) Then
strFilter = strFilter & " And apl = " & Me!cboAPL.Value
End If
If Not IsNull(Me!cboOwner.Value) Then
strFilter = strFilter & " And owner = " & Me!cboOwner.Value
End If
If Not IsNull(Me!cboProjectName.Value) Then
strFilter = strFilter & " And projectName = " & Me!cboProjectName.Value
End If
...etc for the rest of the combo boxes
Docmd.OpenReport stDocName, acPreview, strFilter
End Sub
I've tried to piece together code from past threads. In order to allow the user to select values from multiple combo boxes to filter the report, I think I need code on each combo box on AfterUpdate - I'm just not sure what that code is.
I tried using the "Like" code in the criteria of each field in the query, but there must be too many combo boxes to search on b/c it doesn't work, and then I can't open the query in design mode.
I also am not sure how to search on the start and end dates.
Can someone point me in the right direction? I feel like I'm so close to figuring this out (or maybe that's wishful thinking). :-D
I'm not a VB programmer so I'm a bit confused as to what to do. I have an unbound form with 13 combo boxes and 2 text boxes that the user can type in the start date and end date of a specific field. Each combo box's row source is a query that selects distinct values from what's in the table.
I have a button that opens a report (rptHardwareInformation), and the report's record source is a query (qryTest) with fields from the parent and child tables (tblGeneralInfo and tblHardware). The following is some code that's behind the button:
Private Sub cmdPreview_Click()
On Error GoTo Err_cmdPreview_Click
Dim stDocName As String
Dim strFilter As String
stDocName = "rptHardwareInformation"
strFilter = "1=1 "
If Not IsNull(Me!cboAPL.Value) Then
strFilter = strFilter & " And apl = " & Me!cboAPL.Value
End If
If Not IsNull(Me!cboOwner.Value) Then
strFilter = strFilter & " And owner = " & Me!cboOwner.Value
End If
If Not IsNull(Me!cboProjectName.Value) Then
strFilter = strFilter & " And projectName = " & Me!cboProjectName.Value
End If
...etc for the rest of the combo boxes
Docmd.OpenReport stDocName, acPreview, strFilter
End Sub
I've tried to piece together code from past threads. In order to allow the user to select values from multiple combo boxes to filter the report, I think I need code on each combo box on AfterUpdate - I'm just not sure what that code is.
I tried using the "Like" code in the criteria of each field in the query, but there must be too many combo boxes to search on b/c it doesn't work, and then I can't open the query in design mode.
I also am not sure how to search on the start and end dates.
Can someone point me in the right direction? I feel like I'm so close to figuring this out (or maybe that's wishful thinking). :-D