Results 1 to 2 of 2
  1. #1
    love2waltz is offline Novice
    Windows Vista Access 2003
    Join Date
    May 2012
    Posts
    4

    Help with Control Source

    I have an access report that counts the number of "double" and triple rooms for a group of travelers. I optain the number of rooms by looking at each traveler and their room assignment. If it is a triple room, that means there are 3 people in that room so I count the number of travelers with a triple room assginment and divide by 3 to obtain the number of triple room I need. For a double room, there are 2 people in those rooms so I count the number of travelers with a double room assignment and divide by 2 to obtain the number of double rooms I need.



    The Control Source code I am using for the double room is this

    =-Int(-(Sum(Abs([RoomType]="Double"))/2))

    The Control Source code I am using for the triple room is this

    =-Int(-(Sum(Abs([RoomType]="Triple"))/3))

    This works great however I need to add an additon condition to the double room. I need to also add to count each room type of "DoublX" as an additional room. Not divide it by 2. I haven't been able to figure out how to add the double room/2 plus each DoublX room.

    Any help you can provide is greatly appreciated, thank you.

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    For "Double Room" and "DoubleX" rooms, try:

    = Int(Abs(Sum([RoomType]="Double"))/2) + Abs(Sum([RoomType]="DoublX"))

    (should that be "DoubleX" with an "E"??)


    For the triple room:

    = Int(Abs(Sum([RoomType]="Triple"))/3))


    Why are you using Int() function? Can you have a sum of 5 "Double" rooms? (not including "DoubleX" rooms)
    The Int() function truncates the value to an integer. If you have 5 "Double" rooms (one person wanted a double room) and you divide by 2, you would get 2.5. The int function would result in 2; what happened to the other "room"?

    Seems to me that you would want to round up, not down.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Control Source Error ?
    By bellevue in forum Forms
    Replies: 8
    Last Post: 06-02-2012, 12:47 PM
  2. Replies: 5
    Last Post: 10-13-2011, 03:36 PM
  3. Conditional Control Source
    By tylerg11 in forum Programming
    Replies: 4
    Last Post: 09-26-2011, 07:47 AM
  4. control source
    By nashr1928 in forum Forms
    Replies: 5
    Last Post: 03-12-2011, 09:31 PM
  5. Control Source
    By sarah54 in forum Access
    Replies: 1
    Last Post: 03-07-2011, 09:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums