Filter Subform

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
 
G

gator

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
 
G

gator

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
 
G

gator

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top