Automatic Label Numbering

ChrisMore

Member
Local time
Today, 04:42
Joined
Jan 28, 2020
Messages
185
Hi everyone,

I'm hoping for some assistance in automating label numbers for pallets. I currently have a manually entered Pallet_Number field that stores the pallet number for each item on a shipment and groups the items together so they can be printed on individual pallet labels. However, each pallet label can only contain a maximum of 3 unique items, otherwise it affects the formatting and the information spreads across multiple label sheets when printing. Therefore, I also need a label number field so the items can be grouped by label number instead of pallet number, thus fixing the formatting issue when there are over 3 unique items on one pallet. The label number for each item on a shipment could be manually entered but I would like to explore the possibility of this being automated.

I have attached a screenshot of a mock up in Excel of my database Pallets table to help explain my problem, where I have the Label_Number field automated using the formula shown in the image. The column headings in blue are existing fields in the Pallets table, the yellow column is a helper column for the formula to work in the spreadsheet and the green column is the new Label_Number field to be added to the Pallets table.

As shown in the screenshot, example shipment 10001A consists of 9 pallets but a total of 13 labels because 3 of the pallets have one or more label, as these pallets contain over 3 unique items (Ordered_Item_ID). I have colored the rows to show how the item grouping works for each label in this example.

I am stumped at where to start with this one. I don't know if the Label_Number field can be automated as a calculated field in the Labels report's source query or has to be updated using code as a field in the Pallets table.

Any help would be greatly appreciated.

Thanks,
Chris
 

Attachments

  • 1730971843779.png
    1730971843779.png
    53.3 KB · Views: 18
can you upload your sample xlsx file instead or you can copy the range and paste it on this forum so it is easier to convert to excel.
 
I can see a sensible pattern to work with but what I can't see is the source data.
In these circumstances it is often better to have two samples - The data you have to start with and the secondly the desired output.
So ideally we need two excel sheets - starting data, and expected final output.

The sample should include enough variations to cover all possible scenarios.
 
can you upload your sample xlsx file instead or you can copy the range and paste it on this forum so it is easier to convert to excel.
It says xlsx files aren't supported so I'll have to paste it instead:
Pallet_IDOrder_Shipment_NumberOrdered_Item_IDPallet_NumberPalletCountLabel_NumberPallet_Item_Quantity
000
110001A10011110
210001A10112110
310001A10213110
410001A1051421
510001A10021310
610001A10122310
710001A10223310
810001A10031410
910001A10132410
1010001A10233410
1110001A10041510
1210001A10142510
1310001A10243510
1410001A1064461
1510001A1074561
1610001A1084661
1710001A1094771
1810001A10351815
1910001A10452815
2010001A10061910
2110001A10162910
2210001A10263910
2310001A100711010
2410001A101721010
2510001A102731010
2610001A10574111
2710001A100811210
2810001A101821210
2910001A102831210
3010001A103911315
3110001A104921315
 
I can see a sensible pattern to work with but what I can't see is the source data.
In these circumstances it is often better to have two samples - The data you have to start with and the secondly the desired output.
So ideally we need two excel sheets - starting data, and expected final output.

The sample should include enough variations to cover all possible scenarios.
I feel like there is starting data and expected final output, unless I am misunderstanding you. The column headers highlighted in blue are starting data and the green column is the expected final output.
 
ok, i manually entered some data to this sample db.
open MainForm form and click "Generate Label" button.
Thanks, that's an amazing start! The trouble I can see is the 'PalletCount' field doesn't exist in my database's Pallets table. This was only a helper column for the excel formula to work. Therefore, I would need to add this field to the Pallets table and your code would also need to build that data.

The formula I used for the PalletCount column in my sample spreadsheet is:
=IF(D3>D2,1,E2+1)
 
It says xlsx files aren't supported so I'll have to paste it instead:
Pallet_IDOrder_Shipment_NumberOrdered_Item_IDPallet_NumberPalletCountLabel_NumberPallet_Item_Quantity
000
110001A10011110
210001A10112110
310001A10213110
410001A1051421
510001A10021310
610001A10122310
710001A10223310
810001A10031410
910001A10132410
1010001A10233410
1110001A10041510
1210001A10142510
1310001A10243510
1410001A1064461
1510001A1074561
1610001A1084661
1710001A1094771
1810001A10351815
1910001A10452815
2010001A10061910
2110001A10162910
2210001A10263910
2310001A100711010
2410001A101721010
2510001A102731010
2610001A10574111
2710001A100811210
2810001A101821210
2910001A102831210
3010001A103911315
3110001A104921315
Just change the extension and say what the original was.
 
here is the change and i remove PalletCount from the table.
 

Attachments

Last edited:
here is the change and i remove PalletCount from the table.
Amazing, thanks so much. I'm just wondering, can the below part of the code be ordered by Pallet_Number?

Code:
            Set rs2 = db.OpenRecordset("select pallet_number, label_number from table1 " & _
                        "where ((order_shipment_number) = '" & ![order_shipment_number] & "') and " & _
                        "((label_number) is null) order by pallet_id asc;", dbOpenDynaset)

Reason is, if a Pallet_ID is added with a pallet number out of sequence to the rest, will the label number still be accurate? Pallet_ID 32 in the below table shows this not working correctly with my formula in this scenario.

Pallet_IDOrder_Shipment_NumberOrdered_Item_IDPallet_NumberPalletCountLabel_NumberPallet_Item_Quantity
000
110001A10011110
210001A10112110
310001A10213110
410001A1051421
510001A10021310
610001A10122310
710001A10223310
810001A10031410
910001A10132410
1010001A10233410
1110001A10041510
1210001A10142510
1310001A10243510
1410001A1064461
1510001A1074561
1610001A1084661
1710001A1094771
1810001A10351815
1910001A10452815
2010001A10061910
2110001A10162910
2210001A10263910
2310001A100711010
2410001A101721010
2510001A102731010
2610001A10574111
2710001A100811210
2810001A101821210
2910001A102831210
3010001A103911315
3110001A104921315
3210001A10613131
 
i added Order on the subform, Order by:

order_shipment_number, pallet_number

the same order i added to the vba code.
 

Attachments

i added Order on the subform, Order by:

order_shipment_number, pallet_number

the same order i added to the vba code.
When I run the code it is updating the Label_Number field for all rows in the Pallets table.

How do I amend the code so only the rows are updated for a specific Order_Shipment_Number based on a combo box selection?
 
i added a combobox on the Mainform for you to select.
 

Attachments

Users who are viewing this thread

Back
Top Bottom