DSum() Question

  • Thread starter Thread starter Alan Fisher
  • Start date Start date
A

Alan Fisher

I am using the following line as a control source bu keep
getting an #Error in the text box.

=350-DSum("[HeloHoursFlown]","tblHeloMisnSched"," [
DateStart] > " & "#" & 1/1/2004 & "#")

I used the same line but had "[Evergrren] = -1" in the
criteria instead of the date criteria and it worked fine.
The field name [DateStart] is valid.
 
I am using the following line as a control source bu keep
getting an #Error in the text box.

=350-DSum("[HeloHoursFlown]","tblHeloMisnSched"," [
DateStart] > " & "#" & 1/1/2004 & "#")

I used the same line but had "[Evergrren] = -1" in the
criteria instead of the date criteria and it worked fine.
The field name [DateStart] is valid.

My guess is the name of this control is either "DateStart" or
"HeloHoursFlown".
A control cannot have the same name as the name of a field used in
it's control source expression.

I believe you can code the expression a bit cleaner like this:
=350-DSum("[HeloHoursFlown]","tblHeloMisnSched","[DateStart] >
#1/1/2004#")

If you were going to use a variable date instead of hard coding
"1/1/2004" you could use:
=350-DSum("[HeloHoursFlown]","tblHeloMisnSched"," [DateStart] > #" &
VariableHere & "#")
 
Thanks that did the trick.
-----Original Message-----
I am using the following line as a control source bu keep
getting an #Error in the text box.

=350-DSum("[HeloHoursFlown]","tblHeloMisnSched"," [
DateStart] > " & "#" & 1/1/2004 & "#")

I used the same line but had "[Evergrren] = -1" in the
criteria instead of the date criteria and it worked fine.
The field name [DateStart] is valid.

My guess is the name of this control is either "DateStart" or
"HeloHoursFlown".
A control cannot have the same name as the name of a field used in
it's control source expression.

I believe you can code the expression a bit cleaner like this:
=350-DSum
("[HeloHoursFlown]","tblHeloMisnSched","[DateStart] >
#1/1/2004#")

If you were going to use a variable date instead of hard coding
"1/1/2004" you could use:
=350-DSum("[HeloHoursFlown]","tblHeloMisnSched"," [DateStart] > #" &
VariableHere & "#")

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
 
Alan said:
I am using the following line as a control source bu keep
getting an #Error in the text box.

=350-DSum("[HeloHoursFlown]","tblHeloMisnSched"," [
DateStart] > " & "#" & 1/1/2004 & "#")

I used the same line but had "[Evergrren] = -1" in the
criteria instead of the date criteria and it worked fine.
The field name [DateStart] is valid.


1/1/2004 is an arithmetic expression that evaluates to
..000499, and #.000499# is not a valid date. When you use a
literal date, you need the # and the date inside the
criteria:

. . ., "[DateStart] > #1/1/2004#")

You do need to use concatenation when you're building the
criteria string using a variable:

. . ., "[DateStart] > #" & datevariable & "#")
 

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 Question 1
Retrieving data from query to form 3
DSum #Error 4
dsum with multiple criteria and decimals 0
DSum between dates 1
Public Function Problems 8
Using DSum 1
dsum - 1

Back
Top