Filter a subform based on a Tab Page Selection

Fear Naught

Kevin
Local time
Today, 22:43
Joined
Mar 2, 2006
Messages
229
I am building a system to show all orders and commission payable for the Sales Team in the company I work.

I want to show this as a monthly and year to date figure.

I have setup the main form that works ot my likig and have a subform that shows all orders. What I need ot do is have a tab control with each month as the tabs plus one for all orders. The subform covers all tabs and isn't specific to individual tabs (I tried that but it ran dreadfully slowly).

I have setup an OnChange event for the tab control that sets the filter of the subform to the text on Tab pages (I used a Case Select statment).

I used the following code to set the filter on the subform but I get an error.

Code:
Select Case Me.TabCtl27.Value
    Case 0
        Forms!frmIndividualData_Months!frmRunningTotals_subform.FilterOn = False
   Case 1
        Forms!frmIndividualData_Months!frmRunningTotals_subform.Filter = "[real month]= 'Mar'"
    Case 2
        Forms!frmIndividualData_Months!frmRunningTotals_subform.Filter = "[real month]= 'Apr'"

etc etc

End Select

Forms!frmIndividualData_Months!frmRunningTotals_subform.FilterOn = True

The error is:

Run-Time error 438
Object doesn't support this property or method


Can anybody help either by:

1. Advising on the error and why I may be getting it
or
2. Advising on a better method of filtering a subform based on a Tab Page selection.

Thanks
 
If this:
frmRunningTotals_subform

is the actual name of the subform control (control on the main form which HOUSES the subform) then you should be fine to just add a .Form. between that and the .Filter.

So:

Code:
Forms!frmIndividualData_Months!frmRunningTotals_subform.[B][COLOR=red]Form[/COLOR][/B].Filter = "[real month]= 'Apr'"

But if it is NOT the name of the subform control then you need to use the name of the subform control (along with the .Form.) part. And remember you also have to use the .FilterOn = True part after that part has been set.
 
Hi Bob,

That was a super fast response and fixed my problem - Many thanks.

Why do I also have problems with Forms/Reports references!!! Dohhhh :-)
 

Users who are viewing this thread

Back
Top Bottom