Filter Subform

  • Thread starter Thread starter gator
  • Start date Start date
G

gator

Can someone help me with the correct syntax of the code below. I am trying
to divide one line of code into two lines by using the &_

I can't seem to get any syntax to work.

Private Sub cmbAccount_AfterUpdate()
With Me.DepositsSubform.Form
.Filter = "Account = '" & Me.cmbAccount & "'" And "FundID = '" &
Me.cmbFund & "'" And " &_"
"Month([Date])='" & Me.cmbMonth & "'" And "Year([Date])='" & Me.cmbYear
& "'""
.FilterOn = True
End With
End Sub
 
I'm getting a syntax error...

With Me.DepositsSubform.Form
.Filter = "Account = '" & Me.cmbAccount & "'" And "FundID = '" &
Me.cmbFund & "'" & _
"DatePart("m",[Date])='" & Me.cmbMonth & "'" And "Year([Date])='" &
Me.cmbYear & "'"
.FilterOn = True
End With
 
I'm getting type mismatch....

With Me.DepositsSubform.Form
.Filter = "Account = '" & Me.cmbAccount & "'" And "FundID = '" &
Me.cmbFund & "'" & _
"Month([Date])='" & Me.cmbMonth & "'" And "Year([Date])='" & Me.cmbYear
& "'"
.FilterOn = True
End With
 
Got it...

Private Sub cmbAccount_AfterUpdate()
With Me.DepositsSubform.Form
.Filter = "(Account = '" & Me.cmbAccount & "') And (FundID = '" &
Me.cmbFund & "')AND" & _
"(Month([Date]) = " & Me.cmbMonth & ") And (Year([Date]) = " &
Me.cmbYear & ")"
.FilterOn = True
End With
End Sub
 
Back
Top