calculation in a table?

S

Steve Carpineta

I run a database which holds records for hot air balloon
flights at a recreational hot air ballooning event. I
have tables for Passengers, Pilots, and Flights. One
field of the "Flights" table is "seating capacity.
Balloons hold between 1 - 6 people. I have created a
form wherein there is a subform to list passengers for
each flight. You move through flights on a form viewing
flight information such as pilot and flight time on the
form, and you view the passengers for each flight via the
passenger subform in table view. I have a text box which
carries out a function which looks at the seating
capacity for the flight and subtracts the count of
passengers from it, leaving me with the difference, and
therefore the amount of seats left available on the
flight.

This form is great for looking at flights and determining
how many seats are open. For instance, if I need to find
a spot with three open seats, I can go through the
records until I come across a flight that matches my
needs.

However, I need to be able to query all my flights and
have it return flights which are NOT full, as the bulk of
my passenger additions will be only one person, and
scrolling through takes too long. The problem with this
idea is there is no field in my table to handle "Open
seats," as I rely on an unbound form calculation to
generate this number. Is there a way to get the results
of this function/calculation (seat capacity MINUS count
of passengers for the flight [full seats]) into the table
itself, so that I may run a query to return flights WHERE
SeatsOpen>0 ? I have tried putting calculations in a
field I created in my flight table, but nothing has
worked so far.

I would greatly appreciate any help or ideas. Thanks a
lot,

Steve
 
D

Damon Heron

No need to add a field to your table. Just have a button that runs a query
(or opens a continuous form) to show all open seats.
sort of like: (air code)
SELECT [Flights].FlightID, Sum([Passengers].Capacity) AS [Sum Of Capacity],
Sum([Passengerss].booked) AS [Sum Of booked], ([Sum of Capacity]-[Sum of
booked]) AS OnHand, Flights.FlightName
FROM Flights INNER JOIN ([Passengers] ON Flights.FlightID =
[Passengers].FlightID
GROUP BY [Passengers].FlightID, Flights.FlightName
WHERE - enter your criteria here;

Damon
 

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