Query help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have this query
SELECT DSM.MajorDep, Psychotropic.Prescribed
FROM (Info INNER JOIN DSM ON Info.ResId = DSM.ResId) INNER JOIN Psychotropic
ON Info.ResId = Psychotropic.ResId
GROUP BY DSM.MajorDep, Psychotropic.Prescribed, Info.ResId, Info.TodaysDate
HAVING (((DSM.MajorDep)=1) AND ((Info.ResId)=[whichId]) AND
((Info.TodaysDate)=[todaysDate])) OR (((Psychotropic.Prescribed)=1));

It is asking me for the [whichId] and I enter it. But after I enter it I am
not getting asked the [todaysDate] why is this? I cannot figure out why this
is not coming up.
 
Yep that was it. As soon as I posted this I realized my mistake. hehe

Roger Carlson said:
I'm guessing it's seeing 'Info.TodaysDate' and 'todaysDate' as the same
thing so it always evaluates to TRUE. Try changing the Prompt slightly:
[Todays Date]

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


pokdbz said:
I have this query
SELECT DSM.MajorDep, Psychotropic.Prescribed
FROM (Info INNER JOIN DSM ON Info.ResId = DSM.ResId) INNER JOIN Psychotropic
ON Info.ResId = Psychotropic.ResId
GROUP BY DSM.MajorDep, Psychotropic.Prescribed, Info.ResId, Info.TodaysDate
HAVING (((DSM.MajorDep)=1) AND ((Info.ResId)=[whichId]) AND
((Info.TodaysDate)=[todaysDate])) OR (((Psychotropic.Prescribed)=1));

It is asking me for the [whichId] and I enter it. But after I enter it I am
not getting asked the [todaysDate] why is this? I cannot figure out why this
is not coming up.
 
SELECT DSM.MajorDep, Psychotropic.Prescribed
FROM (Info INNER JOIN DSM ON Info.ResId = DSM.ResId) INNER JOIN Psychotropic
ON Info.ResId = Psychotropic.ResId
WHERE (((Info.ResId)=[whichId]) AND ((Info.TodaysDate)=[hi]))
GROUP BY DSM.MajorDep, Psychotropic.Prescribed
HAVING (((DSM.MajorDep)=1)) OR (((Psychotropic.Prescribed)=1));

Another problem that I am having it is this query is pulling all the dates
not the one specified when you enter the [hi] value.

pokdbz said:
Yep that was it. As soon as I posted this I realized my mistake. hehe

Roger Carlson said:
I'm guessing it's seeing 'Info.TodaysDate' and 'todaysDate' as the same
thing so it always evaluates to TRUE. Try changing the Prompt slightly:
[Todays Date]

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


pokdbz said:
I have this query
SELECT DSM.MajorDep, Psychotropic.Prescribed
FROM (Info INNER JOIN DSM ON Info.ResId = DSM.ResId) INNER JOIN Psychotropic
ON Info.ResId = Psychotropic.ResId
GROUP BY DSM.MajorDep, Psychotropic.Prescribed, Info.ResId, Info.TodaysDate
HAVING (((DSM.MajorDep)=1) AND ((Info.ResId)=[whichId]) AND
((Info.TodaysDate)=[todaysDate])) OR (((Psychotropic.Prescribed)=1));

It is asking me for the [whichId] and I enter it. But after I enter it I am
not getting asked the [todaysDate] why is this? I cannot figure out why this
is not coming up.
 
If Todays Date is always supposed to be today's date, why not hard-code the
Date function into your query?

SELECT DSM.MajorDep, Psychotropic.Prescribed
FROM (Info INNER JOIN DSM ON Info.ResId = DSM.ResId) INNER JOIN Psychotropic
ON Info.ResId = Psychotropic.ResId
GROUP BY DSM.MajorDep, Psychotropic.Prescribed, Info.ResId, Info.TodaysDate
HAVING (((DSM.MajorDep)=1) AND ((Info.ResId)=[whichId]) AND
((Info.TodaysDate)=Date())) OR (((Psychotropic.Prescribed)=1));


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


pokdbz said:
Yep that was it. As soon as I posted this I realized my mistake. hehe

Roger Carlson said:
I'm guessing it's seeing 'Info.TodaysDate' and 'todaysDate' as the same
thing so it always evaluates to TRUE. Try changing the Prompt slightly:
[Todays Date]

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


pokdbz said:
I have this query
SELECT DSM.MajorDep, Psychotropic.Prescribed
FROM (Info INNER JOIN DSM ON Info.ResId = DSM.ResId) INNER JOIN Psychotropic
ON Info.ResId = Psychotropic.ResId
GROUP BY DSM.MajorDep, Psychotropic.Prescribed, Info.ResId, Info.TodaysDate
HAVING (((DSM.MajorDep)=1) AND ((Info.ResId)=[whichId]) AND
((Info.TodaysDate)=[todaysDate])) OR (((Psychotropic.Prescribed)=1));

It is asking me for the [whichId] and I enter it. But after I enter
it I
am
not getting asked the [todaysDate] why is this? I cannot figure out
why
this
is not coming up.
 

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

Back
Top