T
Tal
I need some help filtering the results displayed in a combo box.
I have a combo box "SelectCampaign" that enables the user to choose the
campaign, which then limits the list that can be chosen in the SelectFund
combo box, which then displays a record and limits the list of Fund
Recipients.
That all works great.
Here is the issue:
Funds can be open or closed. I have a Yes/No field set up to define that.
I would like to have command buttons that will filter the SelectFund combo
box to either Show Only Open Funds or Show All Funds.
I have no earthly idea how to add the code for that.
Many thanks for your help.
Here is the current code on my form.
Private Sub cboSelectCampaign_AfterUpdate()
Dim SFundSource As String
SFundSource = "SELECT [tblFunds].[keyFund], [tblFunds].[txtFundName] " & _
"FROM tblFunds " & _
"WHERE [tblFunds].[keyCampaign] = " &
Me.cboSelectCampaign.Value
Me.cboSelectFund.RowSource = SFundSource
Me.cboSelectFund.Requery
End Sub
Private Sub cboSelectFund_AfterUpdate()
Dim strWhere As String
Const strStub = "SELECT * FROM qryClientandFundJunction "
If Not IsNull(Me.cboSelectFund) Then
strWhere = "WHERE (keyFund = " & Me.cboSelectFund & ")"
End If
Forms![frmEditFunds].RecordSource = strStub & strWhere
End Sub
Private Sub cboSelectFund_LostFocus()
Dim SFundRecipientSource As String
SFundRecipientSource = "SELECT DISTINCT
[qryClientandFundJunction].[keyFundRecipient],
[qryClientandFundJunction].[compFileAs],
[qryClientandFundJunction].[txtFundRecipientRelationship] " & _
"FROM qryClientandFundJunction " & _
"WHERE [qryClientandFundJunction].[keyFund] = "
& Me.cboSelectFund.Value
Me.lisSelectRecipient.RowSource = SFundRecipientSource
Me.lisSelectRecipient.Requery
End Sub
Private Sub cboSelectRecipient_LostFocus()
Me!cboSelectRecipient.Value = ""
End Sub
Private Sub Form_Load()
Me.Filter = "(False)"
Me.FilterOn = True
End Sub
Private Sub lisSelectRecipient_AfterUpdate()
Dim strWhere As String
Const strStub = "SELECT * FROM qryClientandFundJunction "
If Not IsNull(Me.lisSelectRecipient) Then
strWhere = "WHERE (keyFundRecipient = " & Me.lisSelectRecipient & ")"
End If
Forms![frmEditFunds].RecordSource = strStub & strWhere
Me!cboSelectFund.Value = ""
Me!cboSelectCampaign.Value = ""
End Sub
I have a combo box "SelectCampaign" that enables the user to choose the
campaign, which then limits the list that can be chosen in the SelectFund
combo box, which then displays a record and limits the list of Fund
Recipients.
That all works great.
Here is the issue:
Funds can be open or closed. I have a Yes/No field set up to define that.
I would like to have command buttons that will filter the SelectFund combo
box to either Show Only Open Funds or Show All Funds.
I have no earthly idea how to add the code for that.
Many thanks for your help.
Here is the current code on my form.
Private Sub cboSelectCampaign_AfterUpdate()
Dim SFundSource As String
SFundSource = "SELECT [tblFunds].[keyFund], [tblFunds].[txtFundName] " & _
"FROM tblFunds " & _
"WHERE [tblFunds].[keyCampaign] = " &
Me.cboSelectCampaign.Value
Me.cboSelectFund.RowSource = SFundSource
Me.cboSelectFund.Requery
End Sub
Private Sub cboSelectFund_AfterUpdate()
Dim strWhere As String
Const strStub = "SELECT * FROM qryClientandFundJunction "
If Not IsNull(Me.cboSelectFund) Then
strWhere = "WHERE (keyFund = " & Me.cboSelectFund & ")"
End If
Forms![frmEditFunds].RecordSource = strStub & strWhere
End Sub
Private Sub cboSelectFund_LostFocus()
Dim SFundRecipientSource As String
SFundRecipientSource = "SELECT DISTINCT
[qryClientandFundJunction].[keyFundRecipient],
[qryClientandFundJunction].[compFileAs],
[qryClientandFundJunction].[txtFundRecipientRelationship] " & _
"FROM qryClientandFundJunction " & _
"WHERE [qryClientandFundJunction].[keyFund] = "
& Me.cboSelectFund.Value
Me.lisSelectRecipient.RowSource = SFundRecipientSource
Me.lisSelectRecipient.Requery
End Sub
Private Sub cboSelectRecipient_LostFocus()
Me!cboSelectRecipient.Value = ""
End Sub
Private Sub Form_Load()
Me.Filter = "(False)"
Me.FilterOn = True
End Sub
Private Sub lisSelectRecipient_AfterUpdate()
Dim strWhere As String
Const strStub = "SELECT * FROM qryClientandFundJunction "
If Not IsNull(Me.lisSelectRecipient) Then
strWhere = "WHERE (keyFundRecipient = " & Me.lisSelectRecipient & ")"
End If
Forms![frmEditFunds].RecordSource = strStub & strWhere
Me!cboSelectFund.Value = ""
Me!cboSelectCampaign.Value = ""
End Sub