Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Help

Status
Not open for further replies.

cranebill

IS-IT--Management
Jan 4, 2002
1,113
US
This should be easy for most people, just i guess im having a brain skip. I need to make a query to pull the last 2 entries in a table. What is the easiest way to be able to do this? Told ya it was easy, but its late on Sunday lol.
 
Do the records have a field with an incrementing ID number? If so, create a query that sorts descending on the ID field and set the query properties to "Top 2".

-Larry
 
No I guess i Should have explained it a little better. Ok this query is to feed a chart on a report. What this report is for is to show the differences between this inspection and the last inspection in a bar graph format. Now this query's data is generated from 3 different tables. The 3rd table does have an ID number but its not sequencial so i just need to print information from this inspection and the one prior is that makes sense.
 
You'll need a field by which you can sort. Just use that field in place of the autonumber field in the first suggestion and you'll be able to take care of this.

Access tables do not store records in the order in which they were entered, so do be careful to create your own way of tracking the order in which your records are entered, if this will be of importance to you. A date field or an autonumber will do just fine for this.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Ok, i have a field that has date of the inspection which i can use as a basis for sorting, I am a little confused however about the "Top 2 " statement in the first comment. Can someone please elaborate on this a bit? So far everything is working except i cannot limit the bar graph to just th last 2 inspections, instead it graphs them all.

Thanx for all the help.
Bill
 
On one of the tool bars is a combo box that now says "All". Change that to 2.

Or, open up the sql window on the query and put "TOP 2" right after the word SELECT.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Thanx guys for the help. It works perfect.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top