From: NeoFax on
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?
From: NeoFax on
On Jun 30, 3:37 pm, NeoFax <NeoFa...(a)gmail.com> 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.
 | 
Pages: 1
Prev: Group By Qtr
Next: Sum values of column