Flying Log query gets wrong results

D

DaveL

Hi
I am trying to write a new query (with QBE) for a Flying Log database. The
idea of the query is that it will tell me the last date I flew in a
particular aircraft. I have got the query working for the two most important
fields: the FlightDate field Total setting is set to 'Last' and I have added
Aircraft type - but I would also like to add to the query two other fields
(from the same query on which I am basing this new query). These fields are
the Departure airport and the Arrival airport. When I added the fields to the
query I thought I was going to get the same results but with just the
additional information of the airports used for each flight. However, adding
the two airport fields just messes up the query results, with it now showing
almost all the flights that I have done. What am I doing wrong please?
 
P

PC Datasheet

In your Totals query, change Last under FlightDate to Max. That will give
you the most current date. Under AircraftType, change Group By to Where and
enter an expression for setting the criteria in this field. Under both
airport fields leave Group By.
 
D

DaveL

Thanks. Sorry if it's obvious, but what expression should I put in the
Aircraft type criteria for Where?
 
P

PC Datasheet

You should have tables like these in your database:
TblFlight
FlightID
FlightDate
AircraftTypeID
DepartureAirport
ArrivalAirport

TblAircraftType
AircraftTypeID
AircraftType

Your query named QryFrmFlight should be based on TblFlight and you should
have a form named FrmFlight based on this query. Your query should contain
all the fields in TblFlight. The criteria for FlightDate should be:
Forms!FrmFlight!DateOfFlight
and the criteria for AircraftTypeID should be:
Forms!FrmFlight!TypeOfAircraft

Your form should contain all the fields in the query except FlightID. Add a
textbox in the formheader and name it DateOfFlight. Add a combobox to the
formheader and name it TypeOfAircraft. Set the RowSource property to
TblAircraftType, set the Bound Column property to 1, set the Column Count
property to 2 and set the Column Width property to 0;2. Put the following
code in the Enter event of the combobox:
If IsNull(Me!DateOfFlight) Then
MsgBox "Enter Flight Date First!",,"Missing Flight Date"
Me!DateOfFlight.SetFocus
End If

Put the following code in the AfterUpdate event of the combobox:
Me.Requery

You will need to enter the Flight Date first. Then when you select the type
of aircraft, your form will automatically show ann the data about that
flight.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top