Combo Box filter subform from a main form (1 Viewer)

debmars

New member
Local time
Today, 09:39
Joined
Dec 5, 2009
Messages
8
Hi

Im designing a bank account subform which is in a main form.
The subform is a continuous form which lists each transaction line with the fields I have listed below.

I have fields in the subform like this

Type(Combo Box) Payments, Receipts, Transfers.

Date Field

Category (Combo Box) e.g Advertising, Fuel, Accounting etc.

Payment Amount (Currency Field)

My question is How can I create a combo box in the main for to filter details in the subform.

I would like to filter Payments receipts and transfers

I would like to filter by selections in the Category combo
And I would like to filter by an amount.

I would appreciate any insight or example

Cheers
Mars
 

Trevor G

Registered User.
Local time
Today, 01:09
Joined
Oct 1, 2009
Messages
2,341
Mars,

Indicated below is code I use to filter from a main form to a subform based on a number of possible combo box selection options

I have highlighted things you will have to rename for your requirements

Private Sub cmdApplyFilter_Click()
'This code will look to filter records in a subform
'It is using 8 string commands
'The form has 8 combo controls
'It is also using individual if statements
'Finally applying the filter on the subform
'Created by Trevor G January 2010
Dim strUWYear As String
Dim strTeam As String
Dim strBroker As String
Dim strInsuredDomicile As String
Dim strPolicy As String
Dim strInsuredName As String


If IsNull(Me.cboTeam.Value) Then
strTeam = "Like '*'"
Else
strTeam = "='" & Me.cboTeam.Value & "'"
End If

If IsNull(Me.cboUWYear.Value) Then
strUWYear = "Like '*'"
Else
strUWYear = "='" & Me.cboUWYear.Value & "'"
End If
If IsNull(Me.cboPolicy.Value) Then
strPolicy = "Like '*'"
Else
strPolicy = "='" & Me.cboPolicy.Value & "'"
End If
If IsNull(Me.cboInsured.Value) Then
strInsuredName = "Like '*'"
Else
strInsuredName = "='" & Me.cboInsured.Value & "'"
End If

If IsNull(Me.cboBroker.Value) Then
strBroker = "Like '*'"
Else
strBroker = "='" & Me.cboBroker.Value & "'"
End If
If IsNull(Me.cboDomicile.Value) Then
strInsuredDomcilie = "Like '*'"
Else
strInsuredDomicile = "='" & Me.cboDomicile.Value & "'"
End If

Me.frmSearchFacilitysubform.Form.Filter = " [Underwriting Year]" & strUWYear & " AND [Policy Reference]" & strPolicy & " AND [Team]" & strTeam _
& " AND [Broker]" & strBroker & " AND [Insured Domicile]" & strInsuredDomicile & " AND [Insured Name]" & strInsuredName
Me.frmSearchFacilitysubform.Form.FilterOn = True
End Sub
 

debmars

New member
Local time
Today, 09:39
Joined
Dec 5, 2009
Messages
8
Wow

Thanks for this. Im going to play around with what you have given me.

Very much appreciated

Cheers

Mars
 

Users who are viewing this thread

Top Bottom