How to split an order in a report or Form (1 Viewer)

cwats

Registered User.
Local time
Today, 09:14
Joined
Feb 20, 2019
Messages
40
I work for a manufacturing company and have been trying to figure out the best way to create a production schedule. The production schedule would contain a product name, order quantity, a production date(when the manufacturing/bottling process would start), and customer name. I can create a schedule with all of that information but i cannot figure out how I can split an order quantity between several days.


For example,



Customer places an order for 10,000 units on a single Purchase Order.



That 10,000 unit order needs to be split up because we cannot produce that in a single day. So the schedule would show something like this,



Total amount ordered: 10,000


(Scheduled for 100% completion in 5 week days @2000 units per day)



Customer Name:

Product Name:
Weekdays Scheduled to Produce: Mon - 2000, Tues - 2000, Weds - 2000, Thurs - 2000, Friday - 2000



We have several customers with hundreds of products each. We would need to schedule them all if ordered.





I am a novice to Access data base development but I do understand the fundamentals. Your advise would be very appreciated.



Thank you,
 

cwats

Registered User.
Local time
Today, 09:14
Joined
Feb 20, 2019
Messages
40
How do I up load a zip file?
 

mike60smart

Registered User.
Local time
Today, 17:14
Joined
Aug 6, 2017
Messages
1,904
To provide db:
copy the db, remove confidential data, run compact & repair, zip w/Windows Compression. Scroll down and use Manage Attachments Manager to select File, Then Click Upload .
Place cursor on blank line and then Click the attachment Icon to select the file you have uploaded.
Click Submit Reply

If you have trouble then send me a zipped copy to me at:-

mike.s23 at outlook.com
 

Mark_

Longboard on the internet
Local time
Today, 09:14
Joined
Sep 12, 2017
Messages
2,111
cwats,

How I would set this up is as follows;
1) Have a table (ProductionLine) that holds your production line data. I am guessing you may already have this, but it would include values such as product, batch prep time, time per item during a run, and maximum quantity per batch.

2) I would create a table (RunSchedule) that is a child to both the Order and to your Production line. This would hold quantity for a run and date/time scheduled to process.

You could then query your RunSchedule to see what is being produced where.
When assigning RunSchedule entries you would first do a total query to see how many units are already scheduled for a given order and show how many remain.

Conceptually is this what you are looking to do?
 

cwats

Registered User.
Local time
Today, 09:14
Joined
Feb 20, 2019
Messages
40
Mark,

Thank you for your reply.

I will try to experiment with what you suggested.

Thanks,

Cwats
 

cwats

Registered User.
Local time
Today, 09:14
Joined
Feb 20, 2019
Messages
40
The type of schedule i want to build would look like a rolling five schedule for weekdays only.

I have tried this with the cross tab table but could not distribute total quantity order over several days.
This is easy to do in excel but i cant figure it out in access.




Something like this,


View attachment prods.zip
 
Last edited:

cwats

Registered User.
Local time
Today, 09:14
Joined
Feb 20, 2019
Messages
40
Mike60Smart Thank you for your help on this. I really do appreciate it.
 

Mark_

Longboard on the internet
Local time
Today, 09:14
Joined
Sep 12, 2017
Messages
2,111
Not sure if you've had a resolution yet, but how I would do something like this is as follows;

1) Set up a way to input the "Start Date" for your calendar. Normally this would default to today but should be able to be updated for future calendars.

2) I would make 5 identical queries each of which has product, schedule date, and quantity. The difference is each would be based on your "Start Date" with the first using that date as is but each of the additional queries adding a day to it.

3) I would then join the queries (similar to a cross tab) so that you have the product and each of the 5 quantities.

4) For the report you would use the same initial date to set the header and add to it for each additional date you are reporting on. You would then just put the matching quantity below.

This is ONE approach that is fairly modular. If you need to add columns you add additional duplicate queries then join them in. The one big advantage is that you can code a function to return "Next Date" that would allow you to skip days not scheduled for production.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:14
Joined
May 21, 2018
Messages
8,527
You need to describe you data better, and provide better data. I cannot see how to build this from what you provided. In building a production schedule normally there is a list of orders to fulfill (items and quantities), list of available resources, and then the buisness rules (constraints and restraints). I do not see any of that.

Here is a previous one I demoed for someone that breaks production amounts by shift and date. Since each shift can only produce so much based on available workers and hours. I also do not work certain days.

So here are the resources (available hours per shift)
tbShift. So shift 1 for example has 126 available production hours.

Code:
Shift	NoOfWorker	TotalTimePerShift
Shift1	18.00	126
Shift2	17.00	119
Shift3	20.00	140

Here are the orders to fulfill. Example it takes 20 hours to build 1 of Product_A, and quantity of 5 are needed.
Code:
OrderProduction	ProductName	Quantity	ProdTimePerUnit	TotalProdTime
1	Product_A	20	5	100
2	Product_B	23	5	115
3	Product_C	26	3	78
4	Product_D	60	6	360
5	Product_E	80	2	160
6	Product_F	43	1	43
7	Product_G	50	7	350
8	Product_H	23	9	207
9	Product_I	53	6	318
10	Product_K	78	4	312
11	Product_L	65	2	130
12	Product_M	34	8	272

The buisness rules are that items are produced in order A to M. There are 3 shifts a day. Work is done 5 days a week.
So I have code to loop the orders, and loop the shifts and apply the available shift hours to a product. If the order is not filled the remaining hours passed to next shift to fill. If the order is filled in a shift they move to the next product.

Code:
Public Sub CreatePlan(StartDay As Date)
  Dim RS_Plan As DAO.Recordset
  Dim RS_Shift As DAO.Recordset
  Dim strSql As String
  Dim RemainingProductionHours As Long 'Current hours left to produce the item
  Dim AvailableHours As Long 'Hours available from the shift
  Dim UsedHours As Long 'Hours used by the shift
  Dim ProductName As String
  Dim ProductionDate As Date
  Dim DayCounter As Long
  Dim ShiftName As String
  Dim reccount As Long  'Number of shifts
  
  'Get the Production plan in a recordset
  strSql = "Select * from tblProductionPlan order by OrderProduction"
  Set RS_Plan = CurrentDb.OpenRecordset(strSql)
  
  'Get the shifts in a recordset
  strSql = "Select * from tblShift order by shift"
  Set RS_Shift = CurrentDb.OpenRecordset(strSql)
  
  'Get the start values
  ProductionDate = StartDay
  AvailableHours = RS_Shift!TotalTimePerShift
  ShiftName = RS_Shift!Shift
  
  'Count the number of shift records
  RS_Shift.MoveLast
  RS_Shift.MoveFirst
  reccount = RS_Shift.RecordCount
  
  'Clear current schedule.  Need to make this table
  CurrentDb.Execute "delete * from tblProductionSchedule"
  
   'Loop all products
   Do While Not RS_Plan.EOF
    ProductName = RS_Plan!ProductName
    RemainingProductionHours = RS_Plan!Quantity * RS_Plan!ProdTimePerUnit
    
    'For each product loop the shifts
    Do
      'The shift has remaining hours to complete the production
      If AvailableHours >= RemainingProductionHours Then
        UsedHours = RemainingProductionHours
        AvailableHours = AvailableHours - RemainingProductionHours
        RemainingProductionHours = 0
      'The shift only has a portion needed to complete production
      Else
        UsedHours = AvailableHours
        RemainingProductionHours = RemainingProductionHours - UsedHours
        AvailableHours = 0
      End If
      'You used some hours from a shift so input into a table the product, shift, hours used, and the date
      strSql = "Insert into tblProductionschedule (ProductName, ShiftName, ShiftHours, ProductionDate) values ('" & ProductName & "', '" & ShiftName & "', " & UsedHours & ", #" & ProductionDate & "#)"
      Debug.Print strSql
      CurrentDb.Execute strSql
      'The shift has no more available hours so move to the next shift
      If AvailableHours = 0 Then
        'If You are at the last shift  move to the first shift the next day
        If RS_Shift.AbsolutePosition = reccount - 1 Then
          RS_Shift.MoveFirst
          'If the next day is saturday move to the next monday
          'Delete this if you work weekends
          If Weekday(ProductionDate) = vbFriday Then
            ProductionDate = ProductionDate + 3
          Else
            ProductionDate = ProductionDate + 1
          End If
        Else
          'You are not at the last shift so just move to the next shift
          RS_Shift.MoveNext
        End If
        'Since you move to a new shift get the name and available shift hours
        AvailableHours = RS_Shift!TotalTimePerShift
        ShiftName = RS_Shift!Shift
      End If
    'Loop until the hours used equal the hours needed to produce it.
    Loop Until RemainingProductionHours = 0
    RS_Plan.MoveNext
  Loop
End Sub


This build the Production Schedule. So as you can see product_A required 100 hours and was completely filled in first shift since they have 126 hours available. They had 26 hours to put against Product B, but shift 2 had to finish the remaining 89 hours.

Code:
ProductName	ShiftName	ShiftHours	ProductionDate
Product_A	Shift1	100	8/12/2016
Product_B	Shift1	26	8/12/2016
Product_B	Shift2	89	8/12/2016
Product_C	Shift2	30	8/12/2016
Product_C	Shift3	48	8/12/2016
Product_D	Shift3	92	8/12/2016
Product_D	Shift1	126	8/15/2016
Product_D	Shift2	119	8/15/2016
Product_D	Shift3	23	8/15/2016
Product_E	Shift3	117	8/15/2016
Product_E	Shift1	43	8/16/2016
Product_F	Shift1	43	8/16/2016
Product_G	Shift1	40	8/16/2016
Product_G	Shift2	119	8/16/2016
Product_G	Shift3	140	8/16/2016
Product_G	Shift1	51	8/17/2016
Product_H	Shift1	75	8/17/2016
Product_H	Shift2	119	8/17/2016
Product_H	Shift3	13	8/17/2016
Product_I	Shift3	127	8/17/2016
Product_I	Shift1	126	8/18/2016
Product_I	Shift2	65	8/18/2016
Product_K	Shift2	54	8/18/2016
Product_K	Shift3	140	8/18/2016
Product_K	Shift1	118	8/19/2016
Product_L	Shift1	8	8/19/2016
Product_L	Shift2	119	8/19/2016
Product_L	Shift3	3	8/19/2016
Product_M	Shift3	137	8/19/2016
Product_M	Shift1	126	8/22/2016
Product_M	Shift2	9	8/22/2016

You can this put this in a crosstab, like you show
Code:
ProductName	8/12/2016	8/15/2016	8/16/2016	8/17/2016	8/18/2016
Product_A	100				
Product_B	115				
Product_C	78				
Product_D	92	268			
Product_E		117	43		
Product_F			43		
Product_G			299	51	
Product_H				207	
Product_I				127	191
Product_K					194
Product_L					
Product_M

If you want more help, please provide some meaningful data. However, this is conceptually what you need to do.
 

Cronk

Registered User.
Local time
Tomorrow, 02:14
Joined
Jul 4, 2013
Messages
2,772
I've not had a call to develop any thing to do with production scheduling. MajP's model would be what I would be aiming for but with a few extra factors provided.


An order to supply might contain more than one product. The ability to re-order priority of orders involving shorter delivery. The production time for a Shift could vary depending on use of overtime. Allowance could be made for actual production varying from expected production per Shift through say, absent workers or machine breakdowns.


Then there would be particular business rules. For example, a particular type of machine is required in the process of making particular products with a bottle neck problems.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:14
Joined
May 21, 2018
Messages
8,527
Yes, this is definitely a very toy problem. But as I said you normally have requirements (things to build or accomplish), resources, and rules. Most of the assignment problems I work are optimizations, so it is not just assigning available resources but assigning the most optimum and efficient. That can get very complicated requiring 10s of thousands of lines of code or more.
 

cwats

Registered User.
Local time
Today, 09:14
Joined
Feb 20, 2019
Messages
40
You need to describe you data better, and provide better data. I cannot see how to build this from what you provided. In building a production schedule normally there is a list of orders to fulfill (items and quantities), list of available resources, and then the buisness rules (constraints and restraints). I do not see any of that.

Here is a previous one I demoed for someone that breaks production amounts by shift and date. Since each shift can only produce so much based on available workers and hours. I also do not work certain days.


........


Product_M[/CODE]If you want more help, please provide some meaningful data. However, this is conceptually what you need to do.
.................


MajP, the Method you described is Brilliant! That is Basically what i am looking to do.


Steps Of Product scheduling:

1. Enter a customer's Product details with the QTY ordered using a Form.

2. Take that product and schedule the QTY for production
3. Have a simplistic way to split that qty over a desired amount of days.

4. Have the ability to go into the schedule and edit the date scheduled or remove the product from schedule.

5. Create a report to email to other production leaders.



I am making this schedule for a Nutraceutical Manufacturer(sports/dietary supps manufacturing). What they want is a way to schedule and update the "Bottling and Packaging" part of the manufacturing process. There are several others - Powder Blending, Capsule Filling, Tablet Pressing, Drink Mix filling and so on. Right now it would be a nightmare to schedule the entire manufacturing process and i am not proficient enough to make such a program in MS Access. (maybe one day though).



I have attached a file that i have made and that file is currently being used by the production manager. I am definetly going to follow your advise and make what you described as your version of a prod. schedule.



Thank you for your ideas and i appreciate the time you have spent on this. View attachment ORDERMGTandPRODSCHEDULE.zip
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:14
Joined
May 21, 2018
Messages
8,527
Good luck, and if you need help I may have other examples. Be advised as pointed out this was a super trivial example and these can get real hard in real life. Normally the determining the resources available at any given time and all the rules surrounding the assignment of resources can be very complicated.
 

cwats

Registered User.
Local time
Today, 09:14
Joined
Feb 20, 2019
Messages
40
Hey Everyone,





Here is one more question,



I neglected to post what mike60smart suggested i do to solve this issue. Attached is a copy of the work he did. He coded some logic into the Customer Schedules form that splits an order qty by the number of days you input. I like this concept. Would there be a way to view every product scheduled in a centralized location that's not a table? That way i could see total production for each day, and, fill days that are empty. I am guessing that i should do a Query to the table that the schedules are stored in, but i wanted to ask for you all first.



So, what I am asking is this,



step 1: (this is already in the DB thanks be to mike60Smart)

1. input new order into production

2. schedule it on the spot



step 2: (this step is what my question is about)

1. Go to the "Schedule Management" page to view all products scheduled (not in the DB)

2. Adjust schedule according to production flow.





Anyways, I appreciate everyone's response to my question. I have three great ideas to work with thanks be to mike60smart, MajP, and Mark_. I want to keep this thread open for a few more days to see what anyone else may suggest. I think i have enough knowledge to make this program.



p.s.


mike60smart,



I apologize for not posting what you suggested on this thread earlier.



Here is the file,


View attachment Order Management V1.zip



Mike
 

mike60smart

Registered User.
Local time
Today, 17:14
Joined
Aug 6, 2017
Messages
1,904
Hi Mike

When you say Al Products Scheduled ?

What do you class as a product scheduled??

You do not have a Status of Scheduled??
 

Mark_

Longboard on the internet
Local time
Today, 09:14
Joined
Sep 12, 2017
Messages
2,111
Two quick questions;
1) Do you have different production lines for different products?
2) Is your goal to have a something that, effectively, pushes back all future production for one line if you find you've had an issues with producing a given run?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:14
Joined
May 21, 2018
Messages
8,527
step 1: (this is already in the DB thanks be to mike60Smart)
1. input new order into production
2. schedule it on the spot

Do not do that! That is wrong is so many ways. Your schedule table needs to be normalized or it will be worthless.

tblOrderSchedule
Code:
  OrderID_FK 'foreign key to the order
  scheduleDate ' date field
  dailyUnits'   long integer

If you need to store units per day, start day, and total schedule days that should go in the order the orders management sheet.

Then you would do an insert query to create a record from start date to number of days with the amount of units per day.
 

Users who are viewing this thread

Top Bottom