By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,155 Members | 2,518 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,155 IT Pros & Developers. It's quick & easy.

Calculating fields from one form to another

P: 111
I have a form that gives the total amount of Cabins that can be booked, broken out into 3 catergories: OV, Inside, and Balcony. The number of each available cabin is entered at the beginning, and as people book cabins (which is done via a combobox on a different form based off of a different table) i need the available number of cabins to reflect those already booked.

Ex: we're given 3 OV cabins, 3 Inside Cabins, and 3 Balcony cabins to start. Someone books an OV cabin - i need the number of OV to go to 2.

I used a simple IF THEN on the AfterUpdate of the CabinCategory Field like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Balcony_Category_AfterUpdate()
  2. If Forms![frmPaxInfo]![Category] = "OV" Then
  3.     Forms![frmCabins]![OVAmt] = Forms![frmCabins]![OVAmt] - 1
  4. End If
  5. If Forms![frmPaxInfo]![Category] = "Inside" Then
  6.     Forms![frmCabins]![InsideAmt] = Forms![frmCabins]![InsideAmt] - 1
  7. End If
  8. If Forms![frmPaxInfo]![Category] = "Balcony" Then
  9.     Forms![frmCabins]![BalconyAmt] = Forms![frmCabins]![BalconyAmt] - 1
  10. End If
  11. End Sub
This works as long as someone doesnt change the category of a cabin, as it will just keep subtracting, and not add back on to the one that was originally there. I know i need to use a query(s) to add up the different types of cabins and then subtract that value from the starting total of each in order to keep the values acurate, but i have no clue how to do this.
Aug 16 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 12,383
You don't normally do it this way.
Usually, you have give each cabin an ID. Then as people book Cabins, you keep track of which CabinID is booked and for what date.

And to find out how many Cabins are free you do a find unmatched query against the date range that they want to book the cabin.
Aug 16 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.