Form to filter report

jeudi 5 mars 2015

I have a form with two option groups on the form and a command button to apply the filter. The form then opens the report based on this filter, I cannot get the filter to apply both option group choices to the report when it open, it only applies one option group choice.



Code in form module:

Private Sub ApplyFilter_Click()

Select Case Me.ChooseYear.VALUE

Case 1

Me.Filter = "year = 2013"

Me.FilterOn = True

Case 2

Me.Filter = "year = 2014"

Me.FilterOn = True

Case 3

Me.Filter = "year = 2015"

Me.FilterOn = True

End Select



Select Case Me.ChooseMonth.VALUE

Case 1

Me.Filter = "Month = 1"

Me.FilterOn = True

Case 2

Me.Filter = "Month = 2"

Me.FilterOn = True

Case 3

Me.Filter = "Month = 3"

Me.FilterOn = True

Case 4

Me.Filter = "Month = 4"

Me.FilterOn = True

Case 5

Me.Filter = "Month = 5"

Me.FilterOn = True

Case 6

Me.Filter = "Month = 6"

Me.FilterOn = True

Case 7

Me.Filter = "Month = 7"

Me.FilterOn = True

Case 8

Me.Filter = "Month = 8"

Me.FilterOn = True

Case 9

Me.Filter = "Month = 9"

Me.FilterOn = True

Case 10

Me.Filter = "Month = 10"

Me.FilterOn = True

Case 11

Me.Filter = "Month = 11"

Me.FilterOn = True

Case 12

Me.Filter = "Month = 12"

Me.FilterOn = True

End Select

If Me.Filter = "" Then

MsgBox "No selection made"

Else

DoCmd.OpenReport "AllShipmentCriteria", acViewReport, , Me.Filter

'Me.FilterOn = True

End If

DoCmd.Close acForm, "AllDateFilter" 'then apply the filter



End Sub

:banghead:

Form to filter report

0 commentaires:

Enregistrer un commentaire

Labels