-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
What's 'QryPrm("frm0", "Entity_ID")'? is it a call to a function? Does
the function read the Control "Entity_ID" on the form "frm0"? If so,
use the query PARAMETERS instead:
PARAMETERS Forms!frm0!Entity_ID Long;
SELECT [Subject], MIN([ApptDate]) As NextAppt
FROM tblAppointments
WHERE ((tblAppointments.Entity_ID=Forms!frm0!Entity_ID ) AND
(tblAppointments.ApptDate>=Date()))
GROUP BY [Subject];
If that Entity_ID is a different data type than Long, change it
accordingly.
If that Entity_ID on the form has more than one Subject, there will be
as many rows returned as there are subjects.
Do you want the first NextAppt or the last NextAppt. For the first:
use MIN(NextAppt). For the last: Max(NextAppt).
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQeiIxIechKqOuFEgEQJi+gCgs8VnS6gSEd0DVjgDwAp5tx DF2JEAn0mp
uy4oefXoz7cHZFIN6ig9xf3j
=dJkJ
-----END PGP SIGNATURE-----
deko wrote:
How do I limit the results of this query to return only the NextAppt and the
corresponding Subject?
SELECT [Subject], MIN([ApptDate]) As NextAppt
FROM tblAppointments
WHERE ((tblAppointments.Entity_ID=QryPrm("frm0", "Entity_ID")) AND
(tblAppointments.ApptDate>=Date()))
GROUP BY [Subject];
The problem with this is that it returns more than one value. If
tblAppointments has:
[ApptDate] [Subject]
2/10/2005 meetingA
2/11/2005 meetingB
2/12/2005 meetingC
I am getting is every record that satisfies the WHERE clause.
What I want is:
2/10/2005 meetingA