Combo Box question

T

Tcs

My books haven't helped, and what I've tried with what I've acquired from this
newsgroup and the mvps website just isn't working.

I have one table with data I want to show. I need two combo boxes to filter my
records. I've been trying to use just one form. I've added my combo boxes to
the Form Header.

Do I need to use a subform instead? Anything else I should know?

Thanks in advance,

Tom
 
R

Rick B

You don't really give enough detail for a good answer.

In short, you would apply a filter to your form or your query based on the
entries in your combo boxes. you could use a requery in your 'after update'
event of the combo boxes.

You'd have to give us more details if you need a more specific answer.

You ask about a subform. The form I use that has combo boxes to filter does
contain a subform with all the records.

In the sample database "Northwinds", there are several good examples. The
"Categories" form is similar to what you want. The "Customer Orders" also
has cool functionality that does a similar function. Neither of these use
combo boxes, but they easily could!

Hope that helps,

Rick B
 
J

Jason

Depending on how often the user will be selecting different criteria, I like
to use a completely different form to select multiple criteria and then use
the criteria in a Where statement when I open the form. Here is some sample
code:

Private Sub cmdOk_Click()
Dim strWhere As String

If IsNull(Me.cmbProject) Then
If IsNull(Me.cmbPhase) Then
If IsNull(Me.cmbPass) Then 'all three are null
DoCmd.Close acForm, "frmVolumeSummary"
Else 'Pass is only one chosen
strWhere = "PassStatus = '" & Me.cmbPass & "'"
End If
Else
If IsNull(Me.cmbPass) Then 'Phase is only one chosen
strWhere = "PhaseName = '" & Me.cmbPhase & "'"
Else 'Phase and Pass chosen
strWhere = "PhaseName = '" & Me.cmbPhase & "'" & " AND " & _
"PassStatus = '" & Me.cmbPass & "'"
End If
End If
Else
If IsNull(Me.cmbPhase) Then
If IsNull(Me.cmbPass) Then 'Project only one chosen
strWhere = "Project = '" & Me.cmbProject & "'"
Else 'Project and Pass chosen
strWhere = "Project = '" & Me.cmbProject & "'" & _
" AND " & "PassStatus = '" & Me.cmbPass & "'"
End If
Else
If IsNull(Me.cmbPass) Then 'Project and Phase chosen
strWhere = "Project = '" & Me.cmbProject & "'" & _
" AND " & "PhaseName = '" & Me.cmbPhase & "'"
Else 'All are chosen
strWhere = "Project = '" & Me.cmbProject & "'" & _
" AND " & "PhaseName = '" & Me.cmbPhase & "'" & _
" AND " & "PassStatus = '" & Me.cmbPass & "'"
End If
End If
End If

DoCmd.OpenForm "frmVolumeSummary", , , strWhere

DoCmd.Close acForm, Me.Name
End Sub
 
Top