Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error when using DSUM and DatePart

Status
Not open for further replies.

bitech

Programmer
May 19, 2001
63
0
0
US
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.
 
How are ya bitech . . .

and this:
Code:
[blue]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')"[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top