![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I am using Access 2003. I have a query which shows a list of club meetings sorted by date. This query is displayed in continuous forms, in a subform. I would like to select a month on the main form which is then used to filter the results for the meeting dates, perhaps by using monthname(month([meeting_date])). I have struggled to find the syntax which will allow me to use the AfterUpdate Event on the combo box to apply and turn on the filter for the subform. Does anyone have a process for applying this sort of filter? Many thanks, Franc. |
#3
| |||
| |||
|
|
Hello, I am using Access 2003. I have a query which shows a list of club meetings sorted by date. This query is displayed in continuous forms, in a subform. I would like to select a month on the main form which is then used to filter the results for the meeting dates, perhaps by using monthname(month([meeting_date])). I have struggled to find the syntax which will allow me to use the AfterUpdate Event on the combo box to apply and turn on the filter for the subform. Does anyone have a process for applying this sort of filter? |
|
Many thanks, Franc. |
#4
| |||
| |||
|
|
franc sutherland wrote: Hello, I am using Access 2003. *I have a query which shows a list of club meetings sorted by date. *This query is displayed in continuous forms, in a subform. *I would like to select a month on the main form which is then used to filter the results for the meeting dates, perhaps by using monthname(month([meeting_date])). I have struggled to find the syntax which will allow me to use the AfterUpdate Event on the combo box to apply and turn on the filter for the subform. Does anyone have a process for applying this sort of filter? Let's say you have MF (main) and SF (subform). *You could do, in the AfterUpdate event of the combo, something like this air code. * * * * Dim strF As String * * * * If not isnull(Me.ComboBoxName) Then * * * * * * * * 'assumes bound column in combo is the month number * * * * * * * * strF = "Month(MeetingDate) = " & Me.ComboBoxName * * * * Endif * * * * Me(SF).Form.Filter = strF * * * * Me(SF).Form.FilterOn = (strF > "") As noted by another, you might want to expand it to filter by year as well. Many thanks, Franc. |
#5
| |||
| |||
|
|
On Oct 8, 4:47 am, Salad <o... (AT) vinegar (DOT) com> wrote: franc sutherland wrote: Hello, I am using Access 2003. I have a query which shows a list of club meetings sorted by date. This query is displayed in continuous forms, in a subform. I would like to select a month on the main form which is then used to filter the results for the meeting dates, perhaps by using monthname(month([meeting_date])). I have struggled to find the syntax which will allow me to use the AfterUpdate Event on the combo box to apply and turn on the filter for the subform. Does anyone have a process for applying this sort of filter? Let's say you have MF (main) and SF (subform). You could do, in the AfterUpdate event of the combo, something like this air code. Dim strF As String If not isnull(Me.ComboBoxName) Then 'assumes bound column in combo is the month number strF = "Month(MeetingDate) = " & Me.ComboBoxName Endif Me(SF).Form.Filter = strF Me(SF).Form.FilterOn = (strF > "") As noted by another, you might want to expand it to filter by year as well. Many thanks, Franc. Hi Salad, Thanks for the tip. Unfortunately I am getting Run-Time Error 13, Type mismatch on the line which reads Me(SF).Form.Filter = strF |
|
Here is the SQL statement for the combo box: SELECT Year([meeting_date]) AS [year], Month([meeting_date]) AS [month] FROM tbl_meeting GROUP BY Year([meeting_date]), Month([meeting_date]) ORDER BY Year([meeting_date]), Month([meeting_date]); The bound column is column 2, month. Any ideas? With regard to filtering by year as well, would this require a second combo box, or is there a way of doing it with just one? |
|
Thanks, Franc. |
#6
| |||
| |||
|
|
On Oct 8, 4:47 am, Salad <o... (AT) vinegar (DOT) com> wrote: franc sutherland wrote: Hello, I am using Access 2003. I have a query which shows a list of club meetings sorted by date. This query is displayed in continuous forms, in a subform. I would like to select a month on the main form which is then used to filter the results for the meeting dates, perhaps by using monthname(month([meeting_date])). I have struggled to find the syntax which will allow me to use the AfterUpdate Event on the combo box to apply and turn on the filter for the subform. Does anyone have a process for applying this sort of filter? Let's say you have MF (main) and SF (subform). You could do, in the AfterUpdate event of the combo, something like this air code. Dim strF As String If not isnull(Me.ComboBoxName) Then 'assumes bound column in combo is the month number strF = "Month(MeetingDate) = " & Me.ComboBoxName Endif Me(SF).Form.Filter = strF Me(SF).Form.FilterOn = (strF > "") As noted by another, you might want to expand it to filter by year as well. Many thanks, Franc. Hi Salad, Thanks for the tip. Unfortunately I am getting Run-Time Error 13, Type mismatch on the line which reads Me(SF).Form.Filter = strF Here is the SQL statement for the combo box: SELECT Year([meeting_date]) AS [year], Month([meeting_date]) AS [month] FROM tbl_meeting GROUP BY Year([meeting_date]), Month([meeting_date]) ORDER BY Year([meeting_date]), Month([meeting_date]); The bound column is column 2, month. Any ideas? With regard to filtering by year as well, would this require a second combo box, or is there a way of doing it with just one? Thanks, Franc. |
#7
| |||
| |||
|
|
franc sutherland wrote: On Oct 8, 4:47 am, Salad <o... (AT) vinegar (DOT) com> wrote: franc sutherland wrote: Hello, I am using Access 2003. *I have a query which shows a list of club meetings sorted by date. *This query is displayed in continuous forms, in a subform. *I would like to select a month on the main form which is then used to filter the results for the meeting dates, perhaps by using monthname(month([meeting_date])). I have struggled to find the syntax which will allow me to use the AfterUpdate Event on the combo box to apply and turn on the filter for the subform. Does anyone have a process for applying this sort of filter? Let's say you have MF (main) and SF (subform). *You could do, in the AfterUpdate event of the combo, something like this air code. * * * *Dim strF As String * * * *If not isnull(Me.ComboBoxName) Then * * * * * * * *'assumes bound column in combo is the month number * * * * * * * *strF = "Month(MeetingDate) = " & Me..ComboBoxName * * * *Endif * * * *Me(SF).Form.Filter = strF * * * *Me(SF).Form.FilterOn = (strF > "") As noted by another, you might want to expand it to filter by year as well. Many thanks, Franc. Hi Salad, Thanks for the tip. *Unfortunately I am getting Run-Time Error 13, Type mismatch on the line which reads Me(SF).Form.Filter = strF Here is the SQL statement for the combo box: SELECT Year([meeting_date]) AS [year], Month([meeting_date]) AS [month] FROM tbl_meeting GROUP BY Year([meeting_date]), Month([meeting_date]) ORDER BY Year([meeting_date]), Month([meeting_date]); The bound column is column 2, month. Any ideas? With regard to filtering by year as well, would this require a second combo box, or is there a way of doing it with just one? Thanks, Franc. One other thing. *You might want to sort the year and month desc thus you get the most recent year/month at the top instead of at the bottom of the list. * * * * Order By 1 Desc, 2 Desc |
![]() |
| Thread Tools | |
| Display Modes | |
| |