Calculating fields from one form to another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Neekos
    New Member
    • Aug 2007
    • 111

    Calculating fields from one form to another

    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:
    [CODE=vb]Private Sub Balcony_Categor y_AfterUpdate()
    If Forms![frmPaxInfo]![Category] = "OV" Then
    Forms![frmCabins]![OVAmt] = Forms![frmCabins]![OVAmt] - 1
    End If
    If Forms![frmPaxInfo]![Category] = "Inside" Then
    Forms![frmCabins]![InsideAmt] = Forms![frmCabins]![InsideAmt] - 1
    End If
    If Forms![frmPaxInfo]![Category] = "Balcony" Then
    Forms![frmCabins]![BalconyAmt] = Forms![frmCabins]![BalconyAmt] - 1
    End If
    End Sub[/CODE]

    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.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    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.

    Comment

    Working...