A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

DSUM Syntax Error



 
 
Thread Tools Display Modes
  #1  
Old June 30th, 2008, 08:37 PM posted to microsoft.public.access.queries
NeoFax
external usenet poster
 
Posts: 85
Default DSUM Syntax Error

I am getting the following suntax error: "Syntax error in string in
query expression '[MonthNum]=6'""(second quote is not in the error
screen). Here is my DSum expression: Test:
DSum("Units","tblMonthlyUnits","[MonthNum]=" &
CStr(DatePart("m",dhpreviousworkdaya(Date()))) & """"). The
tblMonthlyUnits is set up as follows:

MonthNum(Dbl) Sample: 1, 2, 3, 4, 5, ...
MonthName(Txt) Sample: Jan, Feb, Mar, Apr, ...
Units(Dbl) Sample: 2.51, 2.03, 2.67, 1.89, 2.54, ...

Why am I getting the error? If I change the criteria part of the DSum
to "[MonthNum]=6", it works fine. I have tried without changing the
DatePart function to a string, also changing to Double with CDbl and
without change at all and I receive the same error. Could it be the 4
quotation marks at the end?
  #2  
Old June 30th, 2008, 08:49 PM posted to microsoft.public.access.queries
NeoFax
external usenet poster
 
Posts: 85
Default DSUM Syntax Error

On Jun 30, 3:37*pm, NeoFax wrote:
I am getting the following suntax error: "Syntax error in string in
query expression '[MonthNum]=6'""(second quote is not in the error
screen). *Here is my DSum expression: *Test:
DSum("Units","tblMonthlyUnits","[MonthNum]=" &
CStr(DatePart("m",dhpreviousworkdaya(Date()))) & """"). *The
tblMonthlyUnits is set up as follows:

MonthNum(Dbl) Sample: 1, 2, 3, 4, 5, ...
MonthName(Txt) Sample: Jan, Feb, Mar, Apr, ...
Units(Dbl) *Sample: 2.51, 2.03, 2.67, 1.89, 2.54, ...

Why am I getting the error? *If I change the criteria part of the DSum
to "[MonthNum]=6", it works fine. *I have tried without changing the
DatePart function to a string, also changing to Double with CDbl and
without change at all and I receive the same error. *Could it be the 4
quotation marks at the end?


Fixed it myself. Here is the final DSUM:
DSum("Units","tblMonthlyUnits","[MonthNum]=" &
CDbl(DatePart("m",dhpreviousworkdaya(Date())))). Didn't need to
concatenate the quotations as the DatePart returns a number value and
not a string. Now my new dilemma is figuring out how to sum the
values of a column.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:36 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.