DSum not working, please help!

  • Thread starter Thread starter Gina Whipp
  • Start date Start date
G

Gina Whipp

I am trying to get the total hours taken if your time ahs been excused and
all I get is Type Mismatch 13 error. It works if I remove 'And
"[aExcused]=" - 1' but I need that to show me total excused hours. What am
I doing wrong.

Thanks in advance,
Gina

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "'" And "[aExcused]=" - 1)
 
MDB isn't reliable enough for a single user and a single record.

use SQL Server and a subquery instead of this trivial domain aggregate
crap
 
Not EXACTLY the answer I was looking for... NEXT


MDB isn't reliable enough for a single user and a single record.

use SQL Server and a subquery instead of this trivial domain aggregate
crap




Gina said:
I am trying to get the total hours taken if your time ahs been excused
and
all I get is Type Mismatch 13 error. It works if I remove 'And
"[aExcused]=" - 1' but I need that to show me total excused hours. What
am
I doing wrong.

Thanks in advance,
Gina

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "'" And "[aExcused]=" - 1)
 
It looks to me like you've got an extra quote in there, just before the
"And"...it should be:

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "' And "[aExcused]=" - 1)


Also, is aAssociateID a string or a number? If it's a number, that would be
another problem...remove the single quotes.


Rob
 
DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "' And [aExcused]= - 1")
 
Try :
DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "' And [aExcused] = " - 1)

The And has to be inside the quotation marks. By putting the double quote
after the single quote, you have taken it out. Note that AssociateID must be
of type text, otherwise you wouldn't need the single quotes.

Jim B

Gina Whipp said:
I am trying to get the total hours taken if your time ahs been excused and
all I get is Type Mismatch 13 error. It works if I remove 'And
"[aExcused]=" - 1' but I need that to show me total excused hours. What am
I doing wrong.

Thanks in advance,
Gina

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "'" And "[aExcused]=" - 1)
 
aAssociateID is a string

Robert Morley said:
It looks to me like you've got an extra quote in there, just before the
"And"...it should be:

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "' And "[aExcused]=" - 1)


Also, is aAssociateID a string or a number? If it's a number, that would
be another problem...remove the single quotes.


Rob

Gina Whipp said:
I am trying to get the total hours taken if your time ahs been excused and
all I get is Type Mismatch 13 error. It works if I remove 'And
"[aExcused]=" - 1' but I need that to show me total excused hours. What
am I doing wrong.

Thanks in advance,
Gina

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "'" And "[aExcused]=" - 1)
 
Thank you, thank you, thank you....


Douglas J Steele said:
DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "' And [aExcused]= - 1")


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Gina Whipp said:
I am trying to get the total hours taken if your time ahs been excused
and
all I get is Type Mismatch 13 error. It works if I remove 'And
"[aExcused]=" - 1' but I need that to show me total excused hours. What am
I doing wrong.

Thanks in advance,
Gina

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "'" And "[aExcused]=" - 1)
 
Thank you, thank you, thank you....

Robert Morley said:
It looks to me like you've got an extra quote in there, just before the
"And"...it should be:

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "' And "[aExcused]=" - 1)


Also, is aAssociateID a string or a number? If it's a number, that would
be another problem...remove the single quotes.


Rob

Gina Whipp said:
I am trying to get the total hours taken if your time ahs been excused and
all I get is Type Mismatch 13 error. It works if I remove 'And
"[aExcused]=" - 1' but I need that to show me total excused hours. What
am I doing wrong.

Thanks in advance,
Gina

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "'" And "[aExcused]=" - 1)
 
DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "'" And "[aExcused]=" - 1)

The third argument of DSum needs to be constructed as a text string
that looks like a SQL WHERE clause selecting the desired records. In
this case you have the word AND *outside* the string you're building.
In addition, since the -1 is a constant, it should be inside the
quotes. It can be really confusing!

If AssociateID is a Text datatype you need the quotemarks:

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "' And [aExcused]= -1")

If AssociateID is a Number (which would be more common, but I don't
know how your table is set up) you don't need the singlequotes:

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = " &
AssociateID & " And [aExcused]= -1")


John W. Vinson[MVP]
 
aAssociateID is set up as a text per clients request

Thanks for the reply!

John Vinson said:
DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "'" And "[aExcused]=" - 1)

The third argument of DSum needs to be constructed as a text string
that looks like a SQL WHERE clause selecting the desired records. In
this case you have the word AND *outside* the string you're building.
In addition, since the -1 is a constant, it should be inside the
quotes. It can be really confusing!

If AssociateID is a Text datatype you need the quotemarks:

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = '" &
AssociateID & "' And [aExcused]= -1")

If AssociateID is a Number (which would be more common, but I don't
know how your table is set up) you don't need the singlequotes:

DaysOff = DSum("SumOfaTimeDecimal", "qryDaysOff", "aAssociateID = " &
AssociateID & " And [aExcused]= -1")


John W. Vinson[MVP]
 

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

Similar Threads

dsum sytax error 5
select or dsum??? 3
dsum 3
DSUM error# Syntax problem? 4
Dsum with multiple criteria 6
DSum Type Mismatch 3
DSUM Help requested. 0
DSum update query with multiple fields 0

Back
Top