473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Query For Showing Top Record in Linked Tables

I have an Access 97 database with 2 tables, parent one called tblDocuments
and child one named tblRevisions. They are linked with DocID in both tables.

In the revisions table a given DocID can show up numerous times. Another
field named revision will vary in these records.

A query I have will show all instances of a given DocID in the revisions
table. What I want it to do is show the most recent revision, which would be
the one with the maximum revision number for a given docid.

Tips?

LRH
Nov 12 '05 #1
3 3040
In the Query Builder Grid, set Descending in the Sort Line under Revision
Number, rightclick in the top section (but not on one of the tables) and
choose properties, then set 1 under Top Values. That ought to do it.

Larry Linson
Microsoft Access MVP

"Larry R Harrison Jr" <la*******@cox.net> wrote in message
news:B3Dqb.3110$0K6.2275@fed1read06...
I have an Access 97 database with 2 tables, parent one called tblDocuments
and child one named tblRevisions. They are linked with DocID in both tables.
In the revisions table a given DocID can show up numerous times. Another
field named revision will vary in these records.

A query I have will show all instances of a given DocID in the revisions
table. What I want it to do is show the most recent revision, which would be the one with the maximum revision number for a given docid.

Tips?

LRH

Nov 12 '05 #2
"Larry Linson" <bo*****@localhost.not> wrote in message
news:j8****************@nwrddc02.gnilink.net...
In the Query Builder Grid, set Descending in the Sort Line under Revision
Number, rightclick in the top section (but not on one of the tables) and
choose properties, then set 1 under Top Values. That ought to do it.


I did that, but now it only shows it for one doc ID at the time rather than
doing this for all of them.
Nov 12 '05 #3
"Larry R Harrison Jr" wrote
I did that, but now it only shows it for one
doc ID at the time rather than doing this
for all of them.


OK, I didn't read carefully enough.

First, make a totals query: Group By DocID, Max of Revision

Then, create a query including the Document table, the totals query you just
created, and the Revision table. Join the Totals Query and the Document
table on Doc ID, and Join the Totals Query and the Revisions table on Doc ID
and (MaxOfRevision to Revision).

Pull down any other Document and Revision information.

Follow up here if that does not do what you want. Obviously I don't have
your tables, but I tested something similar using the Customers and Orders
tables of the sample Northwind.MDB.

Larry Linson
Microsoft Access MVP
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: jason | last post by:
I could sure use some conceptualization and query help with a Page Watch System I am building in Access 2000 and Asp. I need to cycle through databae and generate a compiliation query email that...
6
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access...
5
by: Sean Byrne | last post by:
We have a Microsoft Access 2000 database consisting of 20 tables covering 20 different events. In each table, there are 3 Team members, a date of the event and several unique fields for the event,...
0
by: ET | last post by:
We have two tables... one with primary key ID and second table with secondary key to the ID in the first table... Now, they query pulls records from both tables, looks like this: SELECT...
6
by: gerbski | last post by:
Hi all, I am relatively new to ADO, but up to now I got things working the way I wanted. But now I've run into somethng really annoying. I am working in MS Access. I am using an Access...
5
by: jonceramic | last post by:
Hi All, I started developing in Access, and people took notice and so we're starting to migrate into our corporate's bigger Oracle system. I'll still be using my developed Access front ends,...
5
by: Bob Bridges | last post by:
Start with two tables, parent records in one and child records in the other, a one-to-many relationship. Create a select statement joining the two. Display the query in datasheet mode. When I...
6
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one...
4
by: franc sutherland | last post by:
Hello, I am using Access 2003. I am having trouble trapping the "can't append all the records in the append query" error message when appending data to a query from a table which is linked to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.