Are you sure that you made it a totals query? Go to design
view, then to View/SQL and copy and paste what you have
there and let us take a look at it.
--
Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
Well I end up with the same number of records, including
duplicate values in
the VisitID column. I mistakenly assumed that I wasn't
clear about the goal
for the query. I appreciate your taking time here.
Should it work as is?
Nick
message
Nick,
I would have thought that what I posted last on creating
a
query to do this would have given you exactly that. What
did
you find different when you set it up that way?
--
Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
Thanks again. I apologize if I may not have been very
clear.
tblVisits.VisitID tblCallInfo.DateOfCall
1 06/02/03
2 01/04/03
3 01/06/03
3 04/11/03
3 01/09/03
4 01/02/03
5 08/08/03
5 01/22/03
6 01/23/03
needs to become...
1 06/02/03
2 01/04/03
3 01/06/03
4 01/02/03
5 01/22/03
6 01/23/03
where only the record with the earliest date for any
VisitID is kept. All
records except the one with the newest DateOfCall
should
be removed "for
each VisitID"
Nick
message
Glad to. Create a query, in your case maybe VisitID
and
Communication. Note that I did not include CallDate.
Now
go
to View/Totals and this will convert it to a Totals
query.
Now in the query grid you will a line for Total
among
others. If you click in the Total line you will get
a
dropdown box arrow. Click on it and you have a
choice of
Accesses 'aggregate' functions. Choose Group for
your
all of
the fields. Now we are going to make a 'contrived
field'
that will be the maximum or last CallDate. In the
next
blank
column put the following in the Field line...
LastCallDate: Max([CallDate])
This should now limit the records to the last
CallDate.
You
will need to modify your controls to refer to
LastCallDate
instead of CallDate.
Regards,
--
Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
message
Thanks Gary. I hate to plead ignorance but I'm
not
sure
how to apply Max()
function. Is this run in vb? Would you mind
pasting
a
very small example?
I'm not much of a coder.
Nick
"Gary Miller" <
[email protected]>
wrote in
message
Nick,
Use the Max() function on the CallDate field in
a
Totals
query and group on the other info.
--
Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
message
I have a query with 2 tables sharing a one to
many
relationship. I want to
show the first instance of a datefield on the
"many"
side
that matches the
primary key of the linked table, while all
subsequent
dates are not shown
for that key value. So while there are 380
records in
tblCalls, around 100
share a VisitID and need to not be shown.
Problem is if I sort the datefield "ascending"
and
apply
TOP1 , I get the
correct number of key fields (280), but all
the
desired
fields from the many
side show blank???
If I sort the datefield "descending" and apply
TOP1, I
only get the newest
(1) record back.
Fields
tblVisits One VisitID
tblCalls Many CallDate
Communication
Why won't this work. Is there another way to
get
the
same
result?
Nick