Hello njanann,
I assume that you have the name of the President as one of the fields ('pName') in the table ('tblPresident') and it is defined as the primary key of the table.
You need to create two queries one to display the name of the youngest President and one for the oldest President.
1) Click 'Insert > Query'.
This will open the 'New Query' dialog box.
2) Select 'Design View' and click 'OK'.
3) This will open the 'Show Table' dialog box. Select the table 'tblPresidents', click'Add' and then 'Close'.
This will close the 'Show Table' dialog box.
4) In the list of fields displayed in the top pane of the Query Design grid (titled 'Query1 : Select Query') double click on 'pName'.
This will add the field in the first columnof the query.
5) In the second column, type the following in the field row:
= DateDiff("yyyy", BirthDate, ElectDate)
The formula will change to Expr1 = DateDiff("yyyy", [BirthDate], [ElectDate])
You can overwrite Expr1 with a variable name (eg 'ElectAge') of your choice. The field name will thus look:
ElectAge = DateDiff("yyyy", [BirthDate], [ElectDate])
6) In the 'Sort' row of the ElectAge field, select 'Descending'.
7) Click in a blank area in the query design (ensuring no field is selected) and click the menu View > Properties.
This will display the 'Query Properties' dialog box.
Set the 'Top values' property to 1.
8) Close saving the query giving the name "Oldest".
When you run this query, it will display the name and age (in years) of the President who was elected at a an age greater than any other President.
9) To find out the youngest President when elected, copy the above query with the name "Youngest" and change the 'Sort' row value of the 'ElectAge' field to 'Ascending'.
SanganakSakha,
Simple And Effective Solutions To Small Problems, No QuickFixes.