PC Review


Reply
Thread Tools Rate Thread

DSum and Dlookup issue

 
 
jtfalk
Guest
Posts: n/a
 
      20th May 2010
Hello,

I have a form that is looks up data based on dates. I want the form to be
kept open and for users to be able to keep changing the dates to get the data
they are looking for.

I have a StartDate and FinishDate box as well as the query behind the form
has dates. I have this so far but am getting numbers way to high for the 2
days I have been looking at 5/13/2010 (129) and 5/14/2010 (193) I was hoping
to get 322 but it is not even close. Thanks

=DSum("nz([Build],0)","Daily Query"," Format([date], ""ddmmyyyy"") >= " &
Format([StartDate],"ddmmyyyy") And " Format([date], ""ddmmyyyy"") <= " &
Format([FinishDate],"ddmmyyyy"))
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      20th May 2010
Your quotes are wrong in the Where Condition part of the statement: the AND
needs to be inside the quotes.

Other things to consider, though, is that converting the dates to strings
formatted as ddmmyyyy will be a problem if you cross over a month boundary
(31052010 is not less than 01062010!!) As well, you're using a reserved
word, Date, as a field name. That's a no-no!

Try:

=DSum("nz([Build],0)","Daily Query","[MyDateField] >= " &
Format([StartDate],"\#yyyy\-mm\-dd\#") & " And [MyDateField] <= " &
Format([FinishDate],"\#yyyy\-mm\-dd\#"))

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"jtfalk" <(E-Mail Removed)> wrote in message
news:B8B77B6B-565D-402F-BECB-(E-Mail Removed)...
> Hello,
>
> I have a form that is looks up data based on dates. I want the form to be
> kept open and for users to be able to keep changing the dates to get the
> data
> they are looking for.
>
> I have a StartDate and FinishDate box as well as the query behind the form
> has dates. I have this so far but am getting numbers way to high for the 2
> days I have been looking at 5/13/2010 (129) and 5/14/2010 (193) I was
> hoping
> to get 322 but it is not even close. Thanks
>
> =DSum("nz([Build],0)","Daily Query"," Format([date], ""ddmmyyyy"") >= " &
> Format([StartDate],"ddmmyyyy") And " Format([date], ""ddmmyyyy"") <= " &
> Format([FinishDate],"ddmmyyyy"))



 
Reply With Quote
 
jtfalk
Guest
Posts: n/a
 
      20th May 2010
Worked great - thanks a lot.

I totally forgot about using Date as a name - it got me before as well.

"Douglas J. Steele" wrote:

> Your quotes are wrong in the Where Condition part of the statement: the AND
> needs to be inside the quotes.
>
> Other things to consider, though, is that converting the dates to strings
> formatted as ddmmyyyy will be a problem if you cross over a month boundary
> (31052010 is not less than 01062010!!) As well, you're using a reserved
> word, Date, as a field name. That's a no-no!
>
> Try:
>
> =DSum("nz([Build],0)","Daily Query","[MyDateField] >= " &
> Format([StartDate],"\#yyyy\-mm\-dd\#") & " And [MyDateField] <= " &
> Format([FinishDate],"\#yyyy\-mm\-dd\#"))
>
> --
> Doug Steele, Microsoft Access MVP
> http://www.AccessMVP.com/DJSteele
> (no e-mails, please!)
>
> "jtfalk" <(E-Mail Removed)> wrote in message
> news:B8B77B6B-565D-402F-BECB-(E-Mail Removed)...
> > Hello,
> >
> > I have a form that is looks up data based on dates. I want the form to be
> > kept open and for users to be able to keep changing the dates to get the
> > data
> > they are looking for.
> >
> > I have a StartDate and FinishDate box as well as the query behind the form
> > has dates. I have this so far but am getting numbers way to high for the 2
> > days I have been looking at 5/13/2010 (129) and 5/14/2010 (193) I was
> > hoping
> > to get 322 but it is not even close. Thanks
> >
> > =DSum("nz([Build],0)","Daily Query"," Format([date], ""ddmmyyyy"") >= " &
> > Format([StartDate],"ddmmyyyy") And " Format([date], ""ddmmyyyy"") <= " &
> > Format([FinishDate],"ddmmyyyy"))

>
>
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DLookup & DSum repaints Kidaeshus Microsoft Access 4 2nd Nov 2009 09:13 PM
DLookup & DSum repaints Kidaeshus Microsoft Access Forms 0 2nd Nov 2009 08:11 PM
dlookup or dsum smason Microsoft Access 4 5th Sep 2008 11:59 AM
Dlookup inside a dsum =?Utf-8?B?YW5keSBzdGFuZm9yZC1qYXNvbg==?= Microsoft Access VBA Modules 1 8th Aug 2007 01:54 PM
DSum and DLookUp giveing #Name? =?Utf-8?B?bmVlbm1hcmll?= Microsoft Access Forms 3 25th Apr 2005 05:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:35 PM.