Here's my code...
Private Sub prev_month_Click()
If Me.hidden_month_clicks = 0 Then
MsgBox "went back to the beginning of the year"
Me.hidden_month_clicks = DatePart("m", Date)
Else
Me.hidden_month_clicks = Me.hidden_month_clicks - 1
Me.Month_NCH.ControlSource = "=DSum('[NCH]','SummaryAux','[Site]=[Forms]![Site]![Site] AND DatePart('yyyy',[Date])=DatePart('yyyy',Date()) AND DatePart('m',[Date])=DatePart('m',Date())-1')"
End If
End Sub
Basically I want the user to be able to click on the prev_month button and the field [Month_NCH] should display the sum of the number of calls handled by a particular site this current year, and previous month. Sounds simple, I've wasted about 2 hrs trying to figure out why I'm getting error messages.
Private Sub prev_month_Click()
If Me.hidden_month_clicks = 0 Then
MsgBox "went back to the beginning of the year"
Me.hidden_month_clicks = DatePart("m", Date)
Else
Me.hidden_month_clicks = Me.hidden_month_clicks - 1
Me.Month_NCH.ControlSource = "=DSum('[NCH]','SummaryAux','[Site]=[Forms]![Site]![Site] AND DatePart('yyyy',[Date])=DatePart('yyyy',Date()) AND DatePart('m',[Date])=DatePart('m',Date())-1')"
End If
End Sub
Basically I want the user to be able to click on the prev_month button and the field [Month_NCH] should display the sum of the number of calls handled by a particular site this current year, and previous month. Sounds simple, I've wasted about 2 hrs trying to figure out why I'm getting error messages.