On 05/09/2013 23:39:24, Scott Sabo wrote:
> Hello-
>
> I have a main form called frmCustomers that has a subform called
> frmTransac tions. On the subform, there are 3 check boxes; 1st contact,
> 2nd contact, a nd 3rd contact. These check boxes show how many times we
> have reached out t o the customer and the associated table carries a date
> to indicate when the contact was made. I did not use a combo box to do
> this as I wanted to be a ble to record a date for each contact attempt.
>
> I have an option group on the main form that i would like to use to filter
> the subform with. The option group has 4 options; No contacts,1 contact, 2
> contacts, 3 contacts. I cannot get the option group to correctly filter
> the subform, below is the code I have put in the AfterUpdate event of the
> opti on group:
>
> Private Sub Frame34_AfterUpdate()
>
> Dim strFilter As String
>
> Select Case [Frame34]
>
> Case 1
> Forms!frmTransactions.Form.FilterOn = False
>
> Case 2
> strFilter = "[Contact 1] = -1"
> Forms!frmTransactions.Form.Filter = strFilter
> Forms!frmTransactions.Form.FilterOn = True
>
> Case 3
> strFilter = "[Contact 2] = -1"
> Forms!frmTransactions.Form.Filter = strFilter
> Forms!frmTransactions.Form.FilterOn = True
>
> Case 4
> strFilter = "[Contact 3] = -1"
> Forms!frmTransactions.Form.Filter = strFilter
> Forms!frmTransactions.Form.FilterOn = True
>
> End Select
>
> End Sub
>
> Any ideas as to why this is not working? I have looked through a ton of
> new sgroup posts and am having a hard time understanding how to write this
> code to control the filtering of the subform. Any help is greatly
> appreciated.
>
> Thanks
>
> Scott
>
I don�t think much of your design. What happens when you decide to contact
your customers 4 times � Redesign? Personally I would use a subform to show
the dates of the contacts, and on the main form enter a number representing
the count of the date. Basically �Show me those customers who have had 2
dates recorded against them)
If you want to do it that way, the option group (depending on setting the
values of the option buttons to 1,2,3,& 4) will return one of those values
So I think your code should be
Private Sub Frame34_AfterUpdate() � The option group
Dim strFilter As String
Select Case [Frame34]
Case 1
CustomerForm!frmTransactions.Form.FilterOn = False
Case 2
strFilter = "[Contact 1] = -1"
CustomerForm!frmTransactions.Form.Filter = strFilter
CustomerForm!frmTransactions.Form.FilterOn = True
Case 3
strFilter = "[Contact 2] = -1"
CustomerForm!frmTransactions.Form.Filter = strFilter
CustomerForm!frmTransactions.Form.FilterOn = True
Case 4
strFilter = "[Contact 3] = -1"
CustomerForm!frmTransactions.Form.Filter = strFilter
CustomerForm!frmTransactions.Form.FilterOn = True
End Select
End Sub
Note the correct way of refering to a subform
Mainform!Subform.form
Phil