filter 3 subforms

L

lilbit27

I am trying to filter the 3 subforms based off of the combo boxes and
textboxes. If I select one cbobox and hit submit it will filter the
first but not the 2nd and 3rd then if I hit submit againthe second and
third subform will filter.

Sumitt is a command button that has the followin code on the
onclick...

Dim stFilter As String
If NZ(Me.cboOpidCCE) <> "" Then stFilter = stFilter & " And [opidcce]
= '" & Me.cboOpidCCE & "'"
If NZ(Me.cboOpidARA) <> "" Then stFilter = stFilter & " And [opidara]
= '" & Me.cboOpidARA & "'"
If NZ(Me.CboProd) <> "" Then stFilter = stFilter & " And [origprodcd]
= '" & Me.CboProd & "'"
If NZ(Me.txtSession) <> "" Then stFilter = stFilter & " And
[origsession] = '" & Me.txtSession & "'"
If NZ(Me.txtPolicy) <> "" Then stFilter = stFilter & " And [cvtpolicy]
= '" & Me.txtPolicy & "'"
If NZ(Me.txtcheck) <> "" Then stFilter = stFilter & " And
[checknumber] = '" & Me.txtcheck & "'"
If NZ(Me.txtStobAmt) <> "" Then stFilter = stFilter & " And [netStob]
= " & Me.txtStobAmt
If Len(stFilter) > 0 Then stFilter = right(stFilter, Len(stFilter) -
5)
Me!FCashApplicationBrokerSub.Form.Filter = stFilter
Me!FCashApplicationBrokerSub2.Form.Filter = stFilter
Me!fCashApplicationBrokersub3.Form.Filter = stFilter
Me!FCashApplicationBrokerSub.Form.FilterOn = True
Me!FCashApplicationBrokerSub2.Form.FilterOn = True
Me!fCashApplicationBrokersub3.Form.FilterOn = True

They are not filtering correctly
 
P

Perry

Without looking at yr code snippet, have you tried to step through
yr code to look at the build up of strFilter?

If not, do so and analyse strFilter...

Krgrds,
Perry
 
P

Perry

Just as a pointer:

Form/Subform mechanism is a powerfull tool of MS Access to let the relations
between
tables/subtables be represented in yr UI.

If you have to enforce this by using filters, perhaps you should consider
redesigning yr datamodell to
regain the Form/Subform power...

Krgrds,
Perry

Perry said:
Without looking at yr code snippet, have you tried to step through
yr code to look at the build up of strFilter?

If not, do so and analyse strFilter...

Krgrds,
Perry

lilbit27 said:
I am trying to filter the 3 subforms based off of the combo boxes and
textboxes. If I select one cbobox and hit submit it will filter the
first but not the 2nd and 3rd then if I hit submit againthe second and
third subform will filter.

Sumitt is a command button that has the followin code on the
onclick...

Dim stFilter As String
If NZ(Me.cboOpidCCE) <> "" Then stFilter = stFilter & " And [opidcce]
= '" & Me.cboOpidCCE & "'"
If NZ(Me.cboOpidARA) <> "" Then stFilter = stFilter & " And [opidara]
= '" & Me.cboOpidARA & "'"
If NZ(Me.CboProd) <> "" Then stFilter = stFilter & " And [origprodcd]
= '" & Me.CboProd & "'"
If NZ(Me.txtSession) <> "" Then stFilter = stFilter & " And
[origsession] = '" & Me.txtSession & "'"
If NZ(Me.txtPolicy) <> "" Then stFilter = stFilter & " And [cvtpolicy]
= '" & Me.txtPolicy & "'"
If NZ(Me.txtcheck) <> "" Then stFilter = stFilter & " And
[checknumber] = '" & Me.txtcheck & "'"
If NZ(Me.txtStobAmt) <> "" Then stFilter = stFilter & " And [netStob]
= " & Me.txtStobAmt
If Len(stFilter) > 0 Then stFilter = right(stFilter, Len(stFilter) -
5)
Me!FCashApplicationBrokerSub.Form.Filter = stFilter
Me!FCashApplicationBrokerSub2.Form.Filter = stFilter
Me!fCashApplicationBrokersub3.Form.Filter = stFilter
Me!FCashApplicationBrokerSub.Form.FilterOn = True
Me!FCashApplicationBrokerSub2.Form.FilterOn = True
Me!fCashApplicationBrokersub3.Form.FilterOn = True

They are not filtering correctly
 
L

lilbit27

Without looking at yr code snippet, have you tried to step through
yr code to look at the build up of strFilter?

If not, do so and analyse strFilter...

Krgrds,
Perry






I am trying to filter the 3 subforms based off of the combo boxes and
textboxes. If I select one cbobox and hit submit it will filter the
first but not the 2nd and 3rd then if I hit submit againthe second and
third subform will filter.
Sumitt is a command button that has the followin code on the
onclick...
Dim stFilter As String
If NZ(Me.cboOpidCCE) <> "" Then stFilter = stFilter & " And [opidcce]
= '" & Me.cboOpidCCE & "'"
If NZ(Me.cboOpidARA) <> "" Then stFilter = stFilter & " And [opidara]
= '" & Me.cboOpidARA & "'"
If NZ(Me.CboProd) <> "" Then stFilter = stFilter & " And [origprodcd]
= '" & Me.CboProd & "'"
If NZ(Me.txtSession) <> "" Then stFilter = stFilter & " And
[origsession] = '" & Me.txtSession & "'"
If NZ(Me.txtPolicy) <> "" Then stFilter = stFilter & " And [cvtpolicy]
= '" & Me.txtPolicy & "'"
If NZ(Me.txtcheck) <> "" Then stFilter = stFilter & " And
[checknumber] = '" & Me.txtcheck & "'"
If NZ(Me.txtStobAmt) <> "" Then stFilter = stFilter & " And [netStob]
= " & Me.txtStobAmt
If Len(stFilter) > 0 Then stFilter = right(stFilter, Len(stFilter) -
5)
Me!FCashApplicationBrokerSub.Form.Filter = stFilter
Me!FCashApplicationBrokerSub2.Form.Filter = stFilter
Me!fCashApplicationBrokersub3.Form.Filter = stFilter
Me!FCashApplicationBrokerSub.Form.FilterOn = True
Me!FCashApplicationBrokerSub2.Form.FilterOn = True
Me!fCashApplicationBrokersub3.Form.FilterOn = True
They are not filtering correctly- Hide quoted text -

- Show quoted text -

I tried this and now it will not work at all. Any thoughts?
Dim stFilter As String
If NZ(Me.cboOpidCCE) <> "" Then
stFilter = stFilter & "[opidcce] = '" & Me.cboOpidCCE & "'"
End If
If NZ(Me.cboOpidARA) <> "" Then
If Len(stFilter) > 0 Then
stFilter = stFilter & " And [opidara] = '" & Me.cboOpidARA & "'"
Else
stFilter = "[opidara] = '" & Me.cboOpidARA & "'"
End If
End If
If NZ(Me.CboProd) <> "" Then
If Len(stFilter) > 0 Then
stFilter = stFilter & " And [origprodcd] = '" & Me.CboProd & "'"
Else
stFilter = "[origprodcd] = '" & Me.CboProd & "'"
End If
End If
If NZ(Me.txtSession) <> "" Then
If Len(stFilter) > 0 Then
stFilter = stFilter & " And [origsession] = '" & Me.txtSession & "'"
Else
stFilter = "[origsession] = '" & Me.txtSession & "'"
End If
Me!FCashApplicationSub.Form.Filter = stFilter
Me!fcashApplicationSub2.Form.Filter = stFilter
Me!fCashApplicationsub3.Form.Filter = stFilter
Me!FCashApplicationSub.Form.FilterOn = True
Me!fcashApplicationSub2.Form.FilterOn = True
Me!fCashApplicationsub3.Form.FilterOn = True
End If
End Sub
 

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

Similar Threads


Top