Multiple Combo Boxes as Criteria for Continuous Form

  • Thread starter Thread starter EmAlbritton via AccessMonster.com
  • Start date Start date
E

EmAlbritton via AccessMonster.com

Morning All.

I have a form that has multiple combo boxes that are criteria for a
continuous form. In a nutshell, users can select any combination of the
combo boxes and click command button that will then list some information
regarding records that currently exist. The purpose of this is so that they
can then select a specific record to update it.

The code for the command button is:

Private Sub Btn_OpenUpdateList_Click()
On Error GoTo Err_Btn_OpenUpdateList_Click

Dim strWhere As String

If Not IsNull(Me.ctrl_MarketSelector) Then
strWhere = strWhere & " AND " & _
"Market = '" & Me.ctrl_MarketSelector & "'"
End If
If Not IsNull(Me.ctrl_ClientSelector) Then
strWhere = strWhere & " AND " & _
"Client = '" & Me.ctrl_ClientSelector & "'"
End If
If Not IsNull(Me.ctrl_CompanySelector) Then
strWhere = strWhere & " AND " & _
"Company = '" & Me.ctrl_CompanySelector & "'"
End If
If Not IsNull(Me.ctrl_CollectorCompanySelector) Then
strWhere = strWhere & " AND " & _
"CollectorCompany = '" & Me.ctrl_CollectorCompanySelector & "'"
End If
If Not IsNull(Me.ctrl_CollectorNameSelector) Then
strWhere = strWhere & " AND " & _
"CollectorName = '" & Me.ctrl_CollectorNameSelector & "'"
End If

If Len(strWhere) > 4 Then strWhere = Right(strWhere, Len(strWhere) - 5)
DoCmd.OpenForm "FrmUpdateListing", , , strWhere


Exit_Btn_OpenUpdateList_Click:
Exit Sub

Err_Btn_OpenUpdateList_Click:
MsgBox Err.Description
Resume Exit_Btn_OpenUpdateList_Click

End Sub


The problem is this...when a choice is made and the command button is
selected, the returned information is repeated. I have tested this with a
selection that is satisfied by only a single record, and it is returned in
the cont. form multiple times.

I don't really know where to go with it. Any help would be appreciated.

Thanks,
emily
 
Disregard this post. I was trying to copy code from a similar form. I
started from scratch with new forms, and pasted the code and it works now.

ea
 
EmAlbritton said:
I have a form that has multiple combo boxes that are criteria for a
continuous form. In a nutshell, users can select any combination of the
combo boxes and click command button that will then list some information
regarding records that currently exist. The purpose of this is so that they
can then select a specific record to update it.

The code for the command button is:

Private Sub Btn_OpenUpdateList_Click()
On Error GoTo Err_Btn_OpenUpdateList_Click

Dim strWhere As String

If Not IsNull(Me.ctrl_MarketSelector) Then
strWhere = strWhere & " AND " & _
"Market = '" & Me.ctrl_MarketSelector & "'"
End If
If Not IsNull(Me.ctrl_ClientSelector) Then
strWhere = strWhere & " AND " & _
"Client = '" & Me.ctrl_ClientSelector & "'"
End If
If Not IsNull(Me.ctrl_CompanySelector) Then
strWhere = strWhere & " AND " & _
"Company = '" & Me.ctrl_CompanySelector & "'"
End If
If Not IsNull(Me.ctrl_CollectorCompanySelector) Then
strWhere = strWhere & " AND " & _
"CollectorCompany = '" & Me.ctrl_CollectorCompanySelector & "'"
End If
If Not IsNull(Me.ctrl_CollectorNameSelector) Then
strWhere = strWhere & " AND " & _
"CollectorName = '" & Me.ctrl_CollectorNameSelector & "'"
End If

If Len(strWhere) > 4 Then strWhere = Right(strWhere, Len(strWhere) - 5)
DoCmd.OpenForm "FrmUpdateListing", , , strWhere


Exit_Btn_OpenUpdateList_Click:
Exit Sub

Err_Btn_OpenUpdateList_Click:
MsgBox Err.Description
Resume Exit_Btn_OpenUpdateList_Click

End Sub


The problem is this...when a choice is made and the command button is
selected, the returned information is repeated. I have tested this with a
selection that is satisfied by only a single record, and it is returned in
the cont. form multiple times.


That code looks like it should do what you want. Since a
filter can not cause extra records to appear, I suspect the
problem is in the form's record source query. Try running
the query directly from the query design window to check
what it is doing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top