Page 2 of 2 FirstFirst 12
Results 16 to 29 of 29
  1. #16
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Not sure how you have the tables set up.
    I had a table for Items and one for Box, because I could process Box out of sequence, I used a FilledBox table also.
    FilledBox could have multiple ItemTypes.

    You want to post a copy of the database you have?

  2. #17
    Pacific1 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2014
    Posts
    12
    BoxAllocation.zip.zip

    Here is the file

  3. #18
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    I don't understand the model nor what exactly you are trying to do. You will have to put the issue into context. Itw ould help if you just used simple English (no Access jargon), until we are both talking about the issue and both understand.

    You have gone from Allocating Items into boxes (item/Box/UsedBox) to a structure of 60 or more tables.

  4. #19
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Please provide details and sample of how transaction fits with the situation. I'm not following the context.

  5. #20
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Pacific1,
    I have sent a PM with a replacement for the FillBoxes. It is called FillBoxesJ. I have tested it with some of your data. Seems OK, but I have made some assumptions based on your code.

    It deals with an aggregate query on the transaction table. Each record is for 1 [Details ID]. It uses FillBoxesJ directly as you have been doing. I did not proceed with creating a function.


    The Item recordset is now defined as:

    Set Item = db.OpenRecordset("SELECT Transaction.[Details ID], Sum(Transaction.QTY) AS DetailID_QTY " _
    ' & " FROM [Transaction] GROUP BY Transaction.[Details ID]")
    '

    Good luck with your project.

  6. #21
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Here is the revised code. And same in attached file.
    Code:
    '---------------------------------------------------------------------------------------
    ' Procedure : FillBoxesJ
    ' Author    : mellon
    ' Date      : 30/11/2014
    ' Purpose   :This is a modified version of FillBoxes. It deals with a query of the transaction table
    ' This query sums up all QTYs for each [Detail ID] so that records are based on each of the [Details ID]
    '
    ' Set Item = db.OpenRecordset("SELECT Transaction.[Details ID], Sum(Transaction.QTY) AS DetailID_QTY " _
    '                               & "  FROM [Transaction] GROUP BY Transaction.[Details ID]")
    '
    'The code has been adjusted to work with this query as the base of the ITEM recordset.
    '---------------------------------------------------------------------------------------
    '
    '
    '
    Public Function FillBoxesJ()
    
    10    gShowDebug = True
              Dim Show As String
              Dim db As DAO.Database
              Dim box As DAO.Recordset
              Dim Item As DAO.Recordset
              Dim BoxesNeeded As Integer                      'Total Boxes needed to process these items
              Dim varSavedBoxID As Variant                    'BoxId in process loop; save it when jumping to part Box
              Dim TotItems As Long                            'Total Items to process
              Dim TotBoxesAvailable As Long                   'Total number of Boxes available (records in tblBox)
              Dim BoxCap As Long                              'Box capacity in units of Items
              Dim wrkItemsQty As Long                         'a variable to deal with Qty of this Item
    
    20        On Error GoTo FillBoxesJ_Error
    
    30        Set db = CurrentDb
    40        Set box = db.OpenRecordset("tblBox")
             ' Set Item = db.OpenRecordset("transaction") XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX THE OLD WAY
             
    50        Set Item = db.OpenRecordset("SELECT Transaction.[Details ID], Sum(Transaction.QTY) AS DetailID_QTY " _
                                         & "  FROM [Transaction] GROUP BY Transaction.[Details ID]")
    
    60        BoxCap = 400
                 
              'Determine How Many Total Boxes are needed to pack all Items
              '       note:
              '            \ is integer divide
              '            / is regular divide
    
    70        TotItems = DSum("Qty", "transaction") 'This was to get all of the Items to be allocated to boxes.
                                                    'it was a test to get some idea of the boxes required.
    
    80        If TotItems / BoxCap > TotItems \ BoxCap Then     'if true there will be overflow
    90            BoxesNeeded = (TotItems \ BoxCap) + 1
    100       Else
    110           BoxesNeeded = TotItems \ BoxCap               'exact capacity of integer number of boxes
    120       End If
    
    130       Item.Close
    140       box.Close
    
    150       If gShowDebug Then Debug.Print "Best guess for Total Boxes Needed for Shipping  " & BoxesNeeded   'initial review close recordsets
    160       TotBoxesAvailable = DCount("*", "tblBox")
    170       If BoxesNeeded > TotBoxesAvailable Then
    180           MsgBox "Insufficient Boxes to process all Items. You need " & BoxesNeeded & " You have only " & TotBoxesAvailable & " --stopping", vbCritical
    190           Exit Function
    200       End If
              '============================above is just checking boxes needed generally ===============================
    
              'db.Execute "Delete * from tblUsedBoxes", dbFailOnError  'Reset the tblUsedBoxes to empty
    
    210       Set box = db.OpenRecordset("tblBox")
             ' Set Item = db.OpenRecordset("transaction") XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX THE OLD WAY
              
    220        Set Item = db.OpenRecordset("SELECT Transaction.[Details ID], Sum(Transaction.QTY) AS DetailID_QTY " _
                                         & "  FROM [Transaction] GROUP BY Transaction.[Details ID]")
    
    230       Do While Not Item.EOF
    240           Do While Not box.EOF
    250               If Item.EOF Then Exit Do     'Do until we run out of items
    260               If gShowDebug Then Debug.Print "processing " & Item!DetailID_QTY & "  units of Item " & Item![Details ID]
    270               wrkItemsQty = Item!DetailID_QTY
    
    Check_WrkItemsVSBoxCapacity:
    280               If wrkItemsQty > box!BoxCapacity Then
    290                   Call PutItemsIntoBox(Item![Details ID], box!BoxCapacity, box!boxid)    ' NO There is Overflow beyond box capacity
    300                   wrkItemsQty = wrkItemsQty - box!BoxCapacity    'adjust the number of items awaiting processing
    310                   If gShowDebug Then Debug.Print "Qty of this Item " & Item![Details ID] & " to process is now  " & wrkItemsQty
    320                   box.MoveNext
    330                   If gShowDebug Then Debug.Print "Box being used is " & box!boxid
    340                   GoTo Check_WrkItemsVSBoxCapacity
    350               Else
    360                   If FindSpace(wrkItemsQty) = 0 Then
    370                       Call PutItemsIntoBox(Item![Details ID], wrkItemsQty, box!boxid)
    380                       box.MoveNext
    390                       GoTo GetNextItem
    400                   Else
    410                       If gShowDebug Then Debug.Print "working Boxno " & box!boxid
    420                       varSavedBoxID = box.Bookmark
    430                       Call PutItemsIntoBox(Item![Details ID], wrkItemsQty, FindSpace(wrkItemsQty))
    440                       box.Bookmark = varSavedBoxID
    450                   End If
    
    460               End If
    
    GetNextItem:
    470               If gShowDebug Then Debug.Print "Finished with Item " & Item![Details ID]
    480               Item.MoveNext  'Get Next Item info from transaction
    490           Loop
    500       Loop
    510       DoCmd.OpenQuery ("ShowFinalBoxAllocation")
    520       On Error GoTo 0
    530       Exit Function
    
    FillBoxesJ_Error:
    
    540       MsgBox "Error " & Err.Number & "  On line [" & Erl & "] (" & Err.Description & ") in procedureFillBoxesJ of Module BoxAlloc"
    
    End Function
    Attached Files Attached Files

  7. #22
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    I just ran your data with the FillBoxesJ procedure. I added a field(FilledAt dateTime default Now) to tblUsedBoxes.
    Here is latest result. ItemIDFK is the [Details ID] from your transaction table.

    BoxIdFK UsedBoxId ItemIDFK ItemQty Transaction ID FilledAt
    1
    3 400 0 01/12/2014 2:52:18 PM
    2
    3 400 0 01/12/2014 2:52:18 PM
    3
    3 400 0 01/12/2014 2:52:18 PM
    4
    4 400 0 01/12/2014 2:52:18 PM
    5
    4 400 0 01/12/2014 2:52:18 PM
    6
    4 400 0 01/12/2014 2:52:18 PM
    7
    4 400 0 01/12/2014 2:52:19 PM
    8
    4 400 0 01/12/2014 2:52:19 PM
    9
    4 400 0 01/12/2014 2:52:19 PM
    10
    4 400 0 01/12/2014 2:52:19 PM
    11
    4 400 0 01/12/2014 2:52:19 PM
    12
    4 400 0 01/12/2014 2:52:19 PM
    13
    4 400 0 01/12/2014 2:52:19 PM
    14
    4 400 0 01/12/2014 2:52:19 PM
    15
    4 400 0 01/12/2014 2:52:19 PM
    16
    4 400 0 01/12/2014 2:52:19 PM
    17
    4 400 0 01/12/2014 2:52:19 PM
    18
    4 400 0 01/12/2014 2:52:19 PM
    19
    4 400 0 01/12/2014 2:52:19 PM
    20
    4 400 0 01/12/2014 2:52:19 PM
    21
    4 400 0 01/12/2014 2:52:19 PM
    22
    5 400 0 01/12/2014 2:52:19 PM
    23
    5 400 0 01/12/2014 2:52:19 PM

  8. #23
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    I have just now found part of the confusion. Do NOT USE table lookups at the Table field level. See this

    Your caption (Product Code) for Product Id sure makes for confusing debugging.

  9. #24
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Pacific1,

    Further to PMs, here is last attempt to work with Transaction level. There are 21 transactions, with a Total Sum of QTY = 9200.
    You will notice that I added 2 fields to tblUsedBoxes --FilledAt and ItemName.

    I have attached files for the source code for these new functions, and the latest copy of the database. I took a copy of your
    database and have added the functions, some queries. You'll run the code from FillBoxesTrans.


    I created another version of FillBoxes called FillBoxesTrans, and created a new Function called PutItemsIntoBoxTrans
    These are included in the attached file. You replace the function FillBoxes with FillBoxesTrans, You replace PutItemsIntoBox
    with PutItemsIntoBoxTrans. Then you run the code from FillBoxesTrans
    Transaction table values being used:
    Transaction ID QTY Product Code Details ID Transaction Note
    1 100 PP002 3
    2 100 PZ004 3
    3 100 PZ023 3
    4 100 PZ103 3
    5 100 PZ100 3
    6 100 PP036 3
    7 100 PZ115 3
    8 100 PP031 3
    9 100 PZ178 3
    10 100 PZ179 3
    11 100 PZ185 3
    12 100 PZ189 3
    13 1900 PP002 4
    14 1900 PP008 4
    15 3400 PP009 4
    16 200 PP002 5
    17 100 PZ023 5
    18 100 PP033 5
    19 100 PP043 5
    20 200 PP061 5
    21 100 PP064 5




    Here is the tblUsedBoxes. ItemIDFK is the transaction id, ItemName is the [Details Id] & " - " & [Prod Id]
    and is an attempt to show you the Product and details going into which Box.
    BoxIdFK is the Box containing this record (transaction/quantity)

    It shows the allocation across 23 boxes
    BoxIdFK UsedBoxId ItemIDFK ItemQty Transaction ID FilledAt ItemName
    1
    1 100 0 01/12/2014 8:04:37 PM 3 - 223
    1
    2 100 0 01/12/2014 8:04:37 PM 3 - 211
    1
    3 100 0 01/12/2014 8:04:37 PM 3 - 218
    1
    4 100 0 01/12/2014 8:04:37 PM 3 - 263
    2
    5 100 0 01/12/2014 8:04:37 PM 3 - 270
    2
    6 100 0 01/12/2014 8:04:37 PM 3 - 236
    2
    7 100 0 01/12/2014 8:04:37 PM 3 - 279
    2
    8 100 0 01/12/2014 8:04:37 PM 3 - 240
    3
    9 100 0 01/12/2014 8:04:37 PM 3 - 280
    3
    10 100 0 01/12/2014 8:04:37 PM 3 - 281
    3
    11 100 0 01/12/2014 8:04:37 PM 3 - 285
    3
    12 100 0 01/12/2014 8:04:37 PM 3 - 289
    4
    13 400 0 01/12/2014 8:04:37 PM 4 - 223
    5
    13 400 0 01/12/2014 8:04:37 PM 4 - 223
    6
    13 400 0 01/12/2014 8:04:37 PM 4 - 223
    7
    13 400 0 01/12/2014 8:04:37 PM 4 - 223
    8
    13 300 0 01/12/2014 8:04:37 PM 4 - 223
    9
    14 400 0 01/12/2014 8:04:37 PM 4 - 225
    10
    14 400 0 01/12/2014 8:04:37 PM 4 - 225
    11
    14 400 0 01/12/2014 8:04:37 PM 4 - 225
    12
    14 400 0 01/12/2014 8:04:37 PM 4 - 225
    13
    14 300 0 01/12/2014 8:04:37 PM 4 - 225
    14
    15 400 0 01/12/2014 8:04:37 PM 4 - 226
    15
    15 400 0 01/12/2014 8:04:37 PM 4 - 226
    16
    15 400 0 01/12/2014 8:04:37 PM 4 - 226
    17
    15 400 0 01/12/2014 8:04:37 PM 4 - 226
    18
    15 400 0 01/12/2014 8:04:37 PM 4 - 226
    19
    15 400 0 01/12/2014 8:04:37 PM 4 - 226
    20
    15 400 0 01/12/2014 8:04:37 PM 4 - 226
    21
    15 400 0 01/12/2014 8:04:37 PM 4 - 226
    22
    15 200 0 01/12/2014 8:04:37 PM 4 - 226
    22
    16 200 0 01/12/2014 8:04:37 PM 5 - 223
    8
    17 100 0 01/12/2014 8:04:37 PM 5 - 218
    13
    18 100 0 01/12/2014 8:04:37 PM 5 - 232
    23
    19 100 0 01/12/2014 8:04:37 PM 5 - 242
    23
    20 200 0 01/12/2014 8:04:37 PM 5 - 244
    23
    21 100 0 01/12/2014 8:04:37 PM 5 - 247

    This is the log of activity as shown in immediate window.
    Code:
    Best guess for Total Boxes Needed for Shipping  23
    processing 100  units of Item 1
    findspace value is 0
    ++ Added 100  units of Item 1 name 3 - 223  to Box 1
    Finished with Item 1
    processing 100  units of Item 2
    findspace value is 1
    working Boxno 2
    findspace value is 1
    ++ Added 100  units of Item 2 name 3 - 211  to Box 1
    Finished with Item 2
    processing 100  units of Item 3
    findspace value is 1
    working Boxno 2
    findspace value is 1
    ++ Added 100  units of Item 3 name 3 - 218  to Box 1
    Finished with Item 3
    processing 100  units of Item 4
    findspace value is 1
    working Boxno 2
    findspace value is 1
    ++ Added 100  units of Item 4 name 3 - 263  to Box 1
    Finished with Item 4
    processing 100  units of Item 5
    findspace value is 0
    ++ Added 100  units of Item 5 name 3 - 270  to Box 2
    Finished with Item 5
    processing 100  units of Item 6
    findspace value is 2
    working Boxno 3
    findspace value is 2
    ++ Added 100  units of Item 6 name 3 - 236  to Box 2
    Finished with Item 6
    processing 100  units of Item 7
    findspace value is 2
    working Boxno 3
    findspace value is 2
    ++ Added 100  units of Item 7 name 3 - 279  to Box 2
    Finished with Item 7
    processing 100  units of Item 8
    findspace value is 2
    working Boxno 3
    findspace value is 2
    ++ Added 100  units of Item 8 name 3 - 240  to Box 2
    Finished with Item 8
    processing 100  units of Item 9
    findspace value is 0
    ++ Added 100  units of Item 9 name 3 - 280  to Box 3
    Finished with Item 9
    processing 100  units of Item 10
    findspace value is 3
    working Boxno 4
    findspace value is 3
    ++ Added 100  units of Item 10 name 3 - 281  to Box 3
    Finished with Item 10
    processing 100  units of Item 11
    findspace value is 3
    working Boxno 4
    findspace value is 3
    ++ Added 100  units of Item 11 name 3 - 285  to Box 3
    Finished with Item 11
    processing 100  units of Item 12
    findspace value is 3
    working Boxno 4
    findspace value is 3
    ++ Added 100  units of Item 12 name 3 - 289  to Box 3
    Finished with Item 12
    processing 1900  units of Item 13
    ++ Added 400  units of Item 13 name 4 - 223  to Box 4
    Qty of this Item 13 to process is now  1500
    Box being used is 5
    ++ Added 400  units of Item 13 name 4 - 223  to Box 5
    Qty of this Item 13 to process is now  1100
    Box being used is 6
    ++ Added 400  units of Item 13 name 4 - 223  to Box 6
    Qty of this Item 13 to process is now  700
    Box being used is 7
    ++ Added 400  units of Item 13 name 4 - 223  to Box 7
    Qty of this Item 13 to process is now  300
    Box being used is 8
    findspace value is 0
    ++ Added 300  units of Item 13 name 4 - 223  to Box 8
    Finished with Item 13
    processing 1900  units of Item 14
    ++ Added 400  units of Item 14 name 4 - 225  to Box 9
    Qty of this Item 14 to process is now  1500
    Box being used is 10
    ++ Added 400  units of Item 14 name 4 - 225  to Box 10
    Qty of this Item 14 to process is now  1100
    Box being used is 11
    ++ Added 400  units of Item 14 name 4 - 225  to Box 11
    Qty of this Item 14 to process is now  700
    Box being used is 12
    ++ Added 400  units of Item 14 name 4 - 225  to Box 12
    Qty of this Item 14 to process is now  300
    Box being used is 13
    findspace value is 0
    ++ Added 300  units of Item 14 name 4 - 225  to Box 13
    Finished with Item 14
    processing 3400  units of Item 15
    ++ Added 400  units of Item 15 name 4 - 226  to Box 14
    Qty of this Item 15 to process is now  3000
    Box being used is 15
    ++ Added 400  units of Item 15 name 4 - 226  to Box 15
    Qty of this Item 15 to process is now  2600
    Box being used is 16
    ++ Added 400  units of Item 15 name 4 - 226  to Box 16
    Qty of this Item 15 to process is now  2200
    Box being used is 17
    ++ Added 400  units of Item 15 name 4 - 226  to Box 17
    Qty of this Item 15 to process is now  1800
    Box being used is 18
    ++ Added 400  units of Item 15 name 4 - 226  to Box 18
    Qty of this Item 15 to process is now  1400
    Box being used is 19
    ++ Added 400  units of Item 15 name 4 - 226  to Box 19
    Qty of this Item 15 to process is now  1000
    Box being used is 20
    ++ Added 400  units of Item 15 name 4 - 226  to Box 20
    Qty of this Item 15 to process is now  600
    Box being used is 21
    ++ Added 400  units of Item 15 name 4 - 226  to Box 21
    Qty of this Item 15 to process is now  200
    Box being used is 22
    findspace value is 0
    ++ Added 200  units of Item 15 name 4 - 226  to Box 22
    Finished with Item 15
    processing 200  units of Item 16
    findspace value is 22
    working Boxno 23
    findspace value is 22
    ++ Added 200  units of Item 16 name 5 - 223  to Box 22
    Finished with Item 16
    processing 100  units of Item 17
    findspace value is 8
    working Boxno 23
    findspace value is 8
    ++ Added 100  units of Item 17 name 5 - 218  to Box 8
    Finished with Item 17
    processing 100  units of Item 18
    findspace value is 13
    working Boxno 23
    findspace value is 13
    ++ Added 100  units of Item 18 name 5 - 232  to Box 13
    Finished with Item 18
    processing 100  units of Item 19
    findspace value is 0
    ++ Added 100  units of Item 19 name 5 - 242  to Box 23
    Finished with Item 19
    processing 200  units of Item 20
    findspace value is 23
    working Boxno 24
    findspace value is 23
    ++ Added 200  units of Item 20 name 5 - 244  to Box 23
    Finished with Item 20
    processing 100  units of Item 21
    findspace value is 23
    working Boxno 24
    findspace value is 23
    ++ Added 100  units of Item 21 name 5 - 247  to Box 23
    Finished with Item 21




    Query2 is just another presentation of the contents of tblUsedBoxes.
    HIghlighting the [Detail Id]
    Query2 SQL
    Code:
    SELECT tblUsedBoxes.BoxIdFK, tblUsedBoxes.ItemName, tblUsedBoxes.ItemIDFK
    , Sum(tblUsedBoxes.ItemQty) AS SumOfItemQty, Left([ItemName],1) AS DetailId
    FROM tblUsedBoxes
    GROUP BY tblUsedBoxes.BoxIdFK, tblUsedBoxes.ItemName, tblUsedBoxes.ItemIDFK, Left([ItemName],1);

    BoxIdFK ItemName ItemIDFK SumOfItemQty DetailId
    1 3 - 211 2 100 3
    1 3 - 218 3 100 3
    1 3 - 223 1 100 3
    1 3 - 263 4 100 3
    2 3 - 236 6 100 3
    2 3 - 240 8 100 3
    2 3 - 270 5 100 3
    2 3 - 279 7 100 3
    3 3 - 280 9 100 3
    3 3 - 281 10 100 3
    3 3 - 285 11 100 3
    3 3 - 289 12 100 3
    4 4 - 223 13 400 4
    5 4 - 223 13 400 4
    6 4 - 223 13 400 4
    7 4 - 223 13 400 4
    8 4 - 223 13 300 4
    8 5 - 218 17 100 5
    9 4 - 225 14 400 4
    10 4 - 225 14 400 4
    11 4 - 225 14 400 4
    12 4 - 225 14 400 4
    13 4 - 225 14 300 4
    13 5 - 232 18 100 5
    14 4 - 226 15 400 4
    15 4 - 226 15 400 4
    16 4 - 226 15 400 4
    17 4 - 226 15 400 4
    18 4 - 226 15 400 4
    19 4 - 226 15 400 4
    20 4 - 226 15 400 4
    21 4 - 226 15 400 4
    22 4 - 226 15 200 4
    22 5 - 223 16 200 5
    23 5 - 242 19 100 5
    23 5 - 244 20 200 5
    23 5 - 247 21 100 5
    Attached Files Attached Files

  10. #25
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Pacific1,

    In response to your recent post, I don't think you can/should restart your Box numbers from 1 for each transaction processed.
    In your earlier requirements you wanted to "fill" each box, that means that when you finish with 1 transaction/quantity of ItemX
    and you move to ItemY -- if you have enough space in a box with some Itemx to contain some ItemY, then the idea was to put that amount
    itemY into the box party filled with ItemX. My feeling is if you restart box numbers with each Item type, you have lost the ability to fill
    those boxes with space available.

    I have included 3 FillBoxes routines- FillBoxes,FillBoxesJ and FillBoxesTrans. The logic throughout is that you start with Box and the loop through all Items.

    However, if you want to start Box number at 1 for each group of Itmes, then get the Item first, fill a Box,see if there're more of the Item to fit and if so
    get another box. When you finish allocating that group of Items, reset your Box number and get a new box.
    I think you have enough info to adjust the code as you need/want it.

    Good luck with the project. Post back if you need help, but let's see what you come up with first.

  11. #26
    Pacific1 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2014
    Posts
    12
    Below is the table tblusedboxes from the attached database. As You can see Box#5 (boxIdfk 5) contains 300 so there is room for 100. The same goes for boxidfk 10. There is 200 total space available. BoxIdfk 19 has 200, so would it be possible to divide up the 200 from Boxidfk 19 into box 5 and 19?


    BoxAllocation.zip.zip



    BoxIdFK UsedBoxId ItemIDFK ItemQty Transaction ID FilledAt ItemName
    1
    13 400 0 12/8/2014 1:58:40 PM 4 - 223
    2
    13 400 0 12/8/2014 1:58:40 PM 4 - 223
    3
    13 400 0 12/8/2014 1:58:40 PM 4 - 223
    4
    13 400 0 12/8/2014 1:58:40 PM 4 - 223
    5
    13 300 0 12/8/2014 1:58:40 PM 4 - 223
    6
    14 400 0 12/8/2014 1:58:40 PM 4 - 225
    7
    14 400 0 12/8/2014 1:58:40 PM 4 - 225
    8
    14 400 0 12/8/2014 1:58:40 PM 4 - 225
    9
    14 400 0 12/8/2014 1:58:40 PM 4 - 225
    10
    14 300 0 12/8/2014 1:58:40 PM 4 - 225
    11
    15 400 0 12/8/2014 1:58:40 PM 4 - 226
    12
    15 400 0 12/8/2014 1:58:40 PM 4 - 226
    13
    15 400 0 12/8/2014 1:58:40 PM 4 - 226
    14
    15 400 0 12/8/2014 1:58:40 PM 4 - 226
    15
    15 400 0 12/8/2014 1:58:40 PM 4 - 226
    16
    15 400 0 12/8/2014 1:58:40 PM 4 - 226
    17
    15 400 0 12/8/2014 1:58:40 PM 4 - 226
    18
    15 400 0 12/8/2014 1:58:40 PM 4 - 226
    19
    15 200 0 12/8/2014 1:58:40 PM 4 - 226
    Attached Files Attached Files

  12. #27
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    What do I enter for OrderNumber? Please be explicit when you ask people to help.

  13. #28
    Pacific1 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2014
    Posts
    12
    Yes, I should have mentioned that. That would be the 'Details ID' from the transaction table. The data given earlier was for details ID '4'

  14. #29
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Here is latest version. See Wrapup procedure description in the module for details.

    Here is result of revised procedures.

    Here is result of ShowFinalBoxAllocation query

    boxidfk itemidfk SumOfItemqty Product Code Product Description
    1 13 400 PP002 BLIZZARD® DARK RED
    2 13 400 PP002 BLIZZARD® DARK RED
    3 13 400 PP002 BLIZZARD® DARK RED
    4 13 400 PP002 BLIZZARD® DARK RED
    5 13 300 PP002 BLIZZARD® DARK RED
    5 15 100 PP009 BLIZZARD® WHITE
    6 14 400 PP008 BLIZZARD® RED
    7 14 400 PP008 BLIZZARD® RED
    8 14 400 PP008 BLIZZARD® RED
    9 14 400 PP008 BLIZZARD® RED
    10 14 300 PP008 BLIZZARD® RED
    10 15 100 PP009 BLIZZARD® WHITE
    11 15 400 PP009 BLIZZARD® WHITE
    12 15 400 PP009 BLIZZARD® WHITE
    13 15 400 PP009 BLIZZARD® WHITE
    14 15 400 PP009 BLIZZARD® WHITE
    15 15 400 PP009 BLIZZARD® WHITE
    16 15 400 PP009 BLIZZARD® WHITE
    17 15 400 PP009 BLIZZARD® WHITE
    18 15 400 PP009 BLIZZARD® WHITE


    You'll notice Box 19 contents have been reallocated to Box5 and Box 10.
    Box 19 removed since not needed.

    BoxIdFK UsedBoxId ItemIDFK ItemQty Transaction ID FilledAt ItemName
    1
    13 400 0 08/12/2014 10:25:46 PM 4 - 223
    2
    13 400 0 08/12/2014 10:25:46 PM 4 - 223
    3
    13 400 0 08/12/2014 10:25:46 PM 4 - 223
    4
    13 400 0 08/12/2014 10:25:46 PM 4 - 223
    5
    13 300 0 08/12/2014 10:25:46 PM 4 - 223
    6
    14 400 0 08/12/2014 10:25:46 PM 4 - 225
    7
    14 400 0 08/12/2014 10:25:46 PM 4 - 225
    8
    14 400 0 08/12/2014 10:25:46 PM 4 - 225
    9
    14 400 0 08/12/2014 10:25:46 PM 4 - 225
    10
    14 300 0 08/12/2014 10:25:46 PM 4 - 225
    11
    15 400 0 08/12/2014 10:25:46 PM 4 - 226
    12
    15 400 0 08/12/2014 10:25:46 PM 4 - 226
    13
    15 400 0 08/12/2014 10:25:46 PM 4 - 226
    14
    15 400 0 08/12/2014 10:25:46 PM 4 - 226
    15
    15 400 0 08/12/2014 10:25:46 PM 4 - 226
    16
    15 400 0 08/12/2014 10:25:46 PM 4 - 226
    17
    15 400 0 08/12/2014 10:25:46 PM 4 - 226
    18
    15 400 0 08/12/2014 10:25:46 PM 4 - 226
    5
    15 100 0 08/12/2014 10:25:46 PM 4 - 226
    10
    15 100 0 08/12/2014 10:25:46 PM 4 - 226
    Attached Files Attached Files
    Last edited by orange; 12-09-2014 at 08:10 AM.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 07-10-2014, 09:37 AM
  2. Replies: 8
    Last Post: 04-01-2014, 02:12 PM
  3. Replies: 8
    Last Post: 04-24-2012, 01:05 PM
  4. products and quantity
    By woody in forum Forms
    Replies: 2
    Last Post: 02-06-2011, 11:58 PM
  5. Orders & Products
    By mastromb in forum Database Design
    Replies: 4
    Last Post: 01-22-2010, 07:59 AM

Tags for this Thread

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