No idea what to call this (1 Viewer)

durdle17

Registered User.
Local time
Today, 05:57
Joined
Feb 21, 2003
Messages
28
Hey,

I have a query with the following code which runs great

SELECT tblstj.hhmm, Sum([tblstj]![acd_calls]+[tblstj]![abn_calls]) AS Total
FROM tblstj
GROUP BY tblstj.hhmm, tblstj.fdate, "All"
HAVING (((tblstj.fdate)=[forms]![frmDailyStats]![txtstdate]));

I want to include this code is the last line but I cannot get it to produce any data

HAVING (((tblstj.fdate)=[forms]![frmDailyStats]![txtstdate] And (tblstj.fdate)=[forms]![frmDailyStats]![txtstdate] + 1)));


Basically I want to add the total to the total of the following day.

Any Suggestions would be great.

Thanks
Chris


**Edit**

Hey pdx,

I am also having trouble tring to repost.

I used this code and now I believe its works great.

SELECT tblstj.hhmm, Sum((([tblstj]![acd_calls]+[tblstj]![abn_calls]))) AS Total
FROM tblstj
WHERE (((tblstj.fdate)=[forms]![frmDailyStats]![txtstdate] Or (tblstj.fdate)=[forms]![frmDailyStats]![txtstdate]+1))
GROUP BY tblstj.hhmm;

Thanks
Chris
 
Last edited:

pdx_man

Just trying to help
Local time
Yesterday, 21:57
Joined
Jan 23, 2001
Messages
1,347
You are currently testing to see if the field equals two different values:

If X=a AND X=b Then ... <---- This will always return no records

Instead, try the OR:

HAVING (((tblstj.fdate)=[forms]![frmDailyStats]![txtstdate] OR (tblstj.fdate)=[forms]![frmDailyStats]![txtstdate] + 1)));

*** EDIT ***

For some reason, I am not able to post a new reply to this thread, but I am able to edit this post, so ...

Hmmm ... So then, let's try this:

SELECT tblstj.hhmm, Sum([tblstj]![acd_calls]+[tblstj]![abn_calls]) AS Total
FROM tblstj
GROUP BY tblstj.hhmm, tblstj.fdate, "All"
HAVING (((tblstj.fdate)=[forms]![frmDailyStats]![txtstdate] OR (tblstj.fdate)=DateAdd('d',1,[forms]![frmDailyStats]![txtstdate]))));

I have used OR operators numerous times in HAVING statements, so ...
I just noticed the All value in your Group By clause. What is that for? Remove that.

You might want to force your parameters to Date/Time datatypes:

CDate([forms]![frmDailyStats]![txtstdate])

If this doesn't work for you, please post a version of your DB in A97.
 
Last edited:

durdle17

Registered User.
Local time
Today, 05:57
Joined
Feb 21, 2003
Messages
28
Hey pdx

I tried the or action just after I posted and that didn't work either.

Thanks for the suggestion.

Chris
 

Vassago

Former Staff Turned AWF Retiree
Local time
Today, 00:57
Joined
Dec 26, 2002
Messages
4,751
If my understanding is correct, you cannot do an OR statement in the Having section of a query. Maybe you should try this one without the TOTALS option. Remove the Group Bys and try it that way.
 

pdx_man

Just trying to help
Local time
Yesterday, 21:57
Joined
Jan 23, 2001
Messages
1,347
Hmmm ... So then, let's try this:

SELECT tblstj.hhmm, Sum([tblstj]![acd_calls]+[tblstj]![abn_calls]) AS Total
FROM tblstj
GROUP BY tblstj.hhmm, tblstj.fdate, "All"
HAVING (((tblstj.fdate)=[forms]![frmDailyStats]![txtstdate] OR (tblstj. fdate)=DateAdd('d',1,[forms]![frmDailyStats]![txts
tdate]))));

I have used OR operators numerous times in HAVING statements, so ...
I just noticed the All value in your Group By clause. What is that for? Remove that.

You might want to force your parameters to Date/Time datatypes:

CDate([forms]![frmDailyStats]![txtstdate])

If this doesn't work for you, please post a version of your DB in A97.
 

Users who are viewing this thread

Top Bottom