# processvariables Analysis generated on: 4/1/2025 5:03:02 PM --- ## VBA Code ```vba Attribute VB_Name = "processvariables" Option Compare Database 'Use database order for string comparisons Global NewPartName_Parm$, PrimaryScreen$, Initforms$, Parts_per_strip!, blankUnits$ Global Sheet_Width!, Sheet_Length!, Actual_PartHeight!, Actual_PartWidth! Global Trim_Cut!, lb_per_sq_ft!, Blocks_Per_Sheet!, src!, PricePerLB! Global Blanks_Per_Block!, parts_per_sheet!, FirstCut!, SecondCut!, SecondShear Global NoGrDirChange, Multi$, TypeDeburr$, MetalName$, MetalPart$, NoDataSheets% Global Grain$, AddnlI%, Pt_Width!, Location%, Gauge$, PMachine$, DescrW, Denting% Global Parts_Per_blank!, Part_Height!, Bottom_Trim_Cut!, FirstCutDir%, UnivREQName$, CalculatedGrossWeight! Global TOP_TRIM_CUT!, Part_Width!, First_Dim!, Second_dim!, dbtype!(20, 2), warehousewc$ Global Elem!(53), Ds$(40), Internal_Labor!, Internal_Walk!, FontTypes%, ExtraShear% Global YESORNO%, YesOrNoStr$, MachinesWithShears$, OutPutData%, PurchaseBlank%, usrID$ Global currform As Form, Directory$, PunchDieDescr$, PunchCounter%, PunchPresserOptions% 'Global StAddnlQDB As Database, StAddnlQSet As Recordset 'Global StAddnlDB As Database, StAddnlSet As Recordset 'Global StMachQDB As Database, StMachQSet As Recordset 'Global StMachQ2DB As Database, StMachQ2Set As Recordset 'Global StAddnlQDB2 As Database, StAddnlQSet2 As Recordset 'Global StMachNamesDB As Database, StMachNamesSet As Recordset 'Global StMainDB As Database, StMainSet As Recordset 'Global StMain2DB As Database, StMain2Set As Recordset 'Global StPressTab As Database, StPressTabSet As Recordset 'Global StMainQDB As Database, StMainQSet As Recordset 'Global StDataShDB As Database, StDataShSet As Recordset 'Global StPressBrk As Database, StPressBrkSet As Recordset 'Global StPunchPress As Database, StPunchPressSet As Recordset 'Global StPressOps As Database, StPressOpsSet As Recordset Sub Add_Additional_Process() Dim AddnlQDB As Database, AddnlQSet As Recordset Dim AddnlDB As Database, AddnlSet As Recordset Dim MachQDB As Database, MachQSet As Recordset Dim Hopc! PartN$ = currform![PartNumber] If currform!SavedProcesses.ListIndex = -1 Then Exit Sub End If Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set search criteria. Set AddnlQDB = DBEngine.Workspaces(0).Databases(0) Set AddnlQSet = AddnlQDB.OpenRecordset("AddnlQ1", DB_OPEN_DYNASET) ' Create dynaset. Set AddnlDB = DBEngine.Workspaces(0).Databases(0) Set AddnlSet = AddnlQDB.OpenRecordset("AddnlPROC", DB_OPEN_TABLE) ' Create dynaset. ' Set AddnlQDB = StAddnlQDB ' Set AddnlQSet = StAddnlQSet ' Set AddnlDB = StAddnlDB ' Set AddnlSet = StAddnlSet wc$ = currform!SavedProcesses.Column(0) Machine$ = currform!SavedProcesses.Column(1) wc1$ = Left$(currform!SavedProcesses.Column(2) + " ", 3) wc2$ = Left$(currform!SavedProcesses.Column(3) + " ", 3) wc3$ = Left$(currform!SavedProcesses.Column(4) + " ", 3) wc4$ = Left$(currform!SavedProcesses.Column(5) + " ", 3) ctime! = currform!SavedProcesses.Column(6) Rstd! = currform!SavedProcesses.Column(7) WCText$ = currform!SavedProcesses.Column(8) AddnlQSet.FindFirst Criteria$ ' Find first occurrence. Hopc = 0 Do Until AddnlQSet.NoMatch ' Loop until no matching records. Generated% = AddnlQSet!Generated ' Get Generation flag. s$ = AddnlQSet!PartNumber If Val(AddnlQSet!OpCode) > Hopc Then Hopc = Val(AddnlQSet!OpCode) End If AddnlQSet.FindNext Criteria$ ' Find next occurrence. Loop ' End of loop. Hopc = ((Hopc \ 10) * 10) + 10 AddnlSet.AddNew AddnlSet!PartNumber = PartN$ AddnlSet!OpCode = Hopc AddnlSet!Generated = False AddnlSet!Description = WCText$ AddnlSet!wc1 = wc1$ AddnlSet!wc2 = wc2$ AddnlSet!wc3 = wc3$ AddnlSet!wc4 = wc4$ AddnlSet!Machine = Machine$ AddnlSet!CycleTime = ctime! AddnlSet!RunStd = Rstd! AddnlSet.Update currform.Refresh End Sub Sub Add_Shear_Verbage(vb$) If Not (SecondShear) Then If Multi$ = "MULTIPLE" Then bt$ = "_(SHEAR OFF " + Format$(Bottom_Trim_Cut!, "#0.00") + Chr$(34) + " BOTTOM" If TOP_TRIM_CUT! > 0 Then bt$ = bt$ + " / " + Format$(TOP_TRIM_CUT!, "#0.00") + Chr$(34) + " TOP" End If bt$ = bt$ + ")" Call AddDescr(vb$, bt$, DescrW) End If End If End Sub Sub AddAPart(Oldpart$, NewPart$, ErrM$) Dim MainDB As Database, MainSet As Recordset Dim Main2DB As Database, Main2Set As Recordset Dim MachNamesDB As Database, MachNamesSet As Recordset Dim MachQDB As Database, MachQSet As Recordset Dim MainTableDef As TableDef Set MainDB = DBEngine.Workspaces(0).Databases(0) Set Main2DB = DBEngine.Workspaces(0).Databases(0) Set MachNamesDB = DBEngine.Workspaces(0).Databases(0) Set MachQDB = DBEngine.Workspaces(0).Databases(0) ErrM$ = " " GoSub Open_Mains1 Set MachNamesSet = MachNamesDB.OpenRecordset("MachineNames", DB_OPEN_TABLE) ' Create dynaset. Set MachQSet = MachQDB.OpenRecordset("Machines", DB_OPEN_TABLE) ' Create dynaset. ' Set MachNamesSet = StMachNamesSet ' Set MachQSet = StMachQSet If (Trim$(Oldpart$) = "") Or (Trim$(NewPart$) = "") Then PartN$ = NewPart$ If PartN$ <> "" Then MainSet.AddNew MainSet!PartNumber = Left$(PartN$, 9) MainSet!PhantomNumber = Left$(PartN$, 9) MainSet!IssueNumber = " " MainSet!GrainNone = True MainSet!Deburr = "Within" MainSet!PrintSize = "B" MainSet!CellDeburrTypes = "Auto" MainSet!PressBrake = 1 ef = 0 On Error GoTo DUPLICATE_rec1 MainSet.Update On Error GoTo 0 If ef = 1 Then Exit Sub End If currform.Refresh If Oldpart$ <> "NEW" Then MainSet.Seek "=", Oldpart$ Main2Set.Seek "=", PartN$ Main2Set.Edit For i = 0 To MainSet.Fields.Count - 1 Main2Set.Fields(i) = MainSet.Fields(i) Next i Main2Set!PartNumber = PartN$ Main2Set.Update GoSub OPEN_Addnl1 MainSet.Seek ">=", Oldpart$ If MainSet.EOF Then Do While Trim$(MainSet!PartNumber) = Oldpart$ Main2Set.AddNew For i = 0 To MainSet.Fields.Count - 1 Main2Set.Fields(i) = MainSet.Fields(i) Next i Main2Set!PartNumber = PartN$ Main2Set.Update MainSet.MoveNext If MainSet.EOF Then Exit Do Loop End If GoSub OPEN_Machs1 MainSet.MoveFirst MainSet.Seek ">=", Oldpart$ If Not (MainSet.NoMatch) Then Do While Trim$(MainSet!PartNumber) = Oldpart$ Main2Set.AddNew For i = 0 To MainSet.Fields.Count - 1 Main2Set.Fields(i) = MainSet.Fields(i) Next i Main2Set!PartNumber = PartN$ Main2Set.Update MainSet.MoveNext If MainSet.EOF Then Exit Do Loop End If GoSub OPEN_Press1 MainSet.MoveFirst MainSet.Seek ">=", Oldpart$ If Not (MainSet.NoMatch) Then Do While Trim$(MainSet!PartNumber) = Oldpart$ Main2Set.AddNew For i = 0 To MainSet.Fields.Count - 1 Main2Set.Fields(i) = MainSet.Fields(i) Next i Main2Set!PartNumber = PartN$ Main2Set.Update MainSet.MoveNext If MainSet.EOF Then Exit Do Loop End If GoSub Open_Mains1 End If End If End If ErrM$ = "Part " + PartN$ + " added" Exit Sub Open_Mains1: Set MainSet = MainDB.OpenRecordset("Process", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = MainDB.OpenRecordset("Process", DB_OPEN_TABLE) ' Create dynaset. MainSet.Index = "PrimaryKey" Main2Set.Index = "PrimaryKey" Return OPEN_Addnl1: Set MainSet = MainDB.OpenRecordset("AddnlProc", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("AddnlProc", DB_OPEN_TABLE) ' Create dynaset. ' Set mainset = StAddnlSet ' Set main2Set = StAddnlSet MainSet.Index = "PartNumber" Main2Set.Index = "PartNumber" Return OPEN_Machs1: Set MainSet = MainDB.OpenRecordset("Machines", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("Machines", DB_OPEN_TABLE) ' Create dynaset. ' Set mainset = StMachQSet ' Set main2Set = StMachQSet MainSet.Index = "PartNumber" Main2Set.Index = "PartNumber" currform.Refresh Return OPEN_Press1: Set MainSet = MainDB.OpenRecordset("PressBrakeOPs", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("PressBrakeOPs", DB_OPEN_TABLE) ' Create dynaset ' Set mainset = StPressOpsSet ' Set main2Set = StPressOpsSet MainSet.Index = "PartNumber" Main2Set.Index = "PartNumber" currform.Refresh Return DUPLICATE_rec1: ErrM$ = "Duplicate record - " + PartN$ ef = 1 Resume Next End Sub Sub AddDescr(pbd$, C1$, DescrWX) c2$ = C1$ pbda$ = RTrim$(pbd$) If Len(pbd$) <> Len(pbda$) Then pbd$ = pbda$ + " " End If Do Di% = InStr(c2$, "`") If Di% <> 0 Then d1$ = Left$(c2$, Di% - 1) c2$ = Mid$(c2$, Di% + 1) GoSub AddIt Else d1$ = c2$ GoSub AddIt Exit Do End If Loop For i = 1 To Len(pbd$) If Mid$(pbd$, i, 1) = "_" Then Mid$(pbd$, i, 1) = " " End If Next Exit Sub AddIt: Do lPBD = Len(pbd$) x% = lPBD \ DescrWX rPBD% = lPBD - (x% * DescrWX) nxPBD% = (x% + 1) * DescrWX dd$ = d1$ If Len(d1$) > (DescrWX - rPBD%) Then d1l% = instrl(Left$(d1$, (DescrWX - rPBD%)), " ") If d1l% < DescrWX - rPBD% Then dd$ = Left$(d1$, d1l%) d1$ = Mid$(d1$, d1l% + 1) Else d1$ = "" End If Else d1$ = "" End If If dd$ = "" Then Exit Do ' If rPBD% + Len(dd$) > DescrWX Then ' pbd$ = Left$(RTrim$(pbd$) + dd$ + String$(nxPBD%, "_"), nxPBD%) pbd$ = Left$(pbd$ + dd$ + String$(nxPBD%, "_"), nxPBD%) ' Else ' pbd$ = Left$(RTrim$(pbd$) + dd$ + String$(nxPBD%, "_"), nxPBD%) ' End If Loop Return End Sub Function AddnlHandDeburr!() Addnl = currform!AddnlDeburrInches AddnlHandDeburr! = Addnl * 0.002 * 60 End Function Sub AddPartButton() On Error GoTo Err_addPr_Click Dim DocName As String Dim LinkCriteria As String DoCmd.Close DocName = "New Process Sheet" DoCmd.OpenForm DocName, , , LinkCriteria Exit_addPr_Click: Exit Sub Err_addPr_Click: MsgBox Error$ Resume Exit_addPr_Click End Sub Sub CalcActualWt(dim1!, dim2!, Aw!) ' ' lb_per_sq_ft ' If (lb_per_sq_ft! = 0) Then Exit Sub Aw! = dim1! * dim2! / 144 * lb_per_sq_ft! Aw! = Val(Format$(Aw!, "######0.000")) End Sub ' Sub CalcGrossWeight(dim1!, dim2!, Gw!, Aw!, RC%) Dim A%, b% RC% = 0 ' 'Input: ' Sheet.Width ' Sheet.Length ' Trim.Cut ' lb_per_sq_ft ' 'Output: ' Blocks.Per.Sheet ' Blanks.Per.Block ' Parts.Per.Sheet ' If (dim1! = 0) Or (dim2! = 0) Or (lb_per_sq_ft! = 0) Then RC% = 6 Exit Sub End If ' + mod 23-jan-97 ASheet_Width! = Sheet_Width! ASheet_Length! = Sheet_Length! If dim1! < 2 Then ASheet_Length! = ASheet_Length! - 2 If dim2! < 2 Then ASheet_Width! = ASheet_Width! - 2 ' - mod 23-jan-97 If Multi$ = "BLANK" Then A% = 1 Else A% = Int((ASheet_Width! - Trim_Cut) / dim2!) End If b% = Int((ASheet_Length! - Trim_Cut) / dim1!) C% = 1 'for punch press Parts_per_strip! = 1 If (Multi$ = "NO CNC") Then If (PunchDieDescr$ <> "!NONE!") Then Parts_per_strip! = PunchCounter% C% = Parts_per_strip! If b% <= 0 Then b% = 1 If PunchPresserOptions% <> 1 Then A% = Parts_per_strip! C% = 1 End If End If End If Blocks_Per_Sheet = b% Blanks_Per_Block = A% OFFALL1 = ASheet_Length! - Trim_Cut! - dim1! * Blocks_Per_Sheet OFFALL2 = ASheet_Width! - Trim_Cut! - dim2! * Blanks_Per_Block Rot1 = False: Rot2 = False If (OFFALL1 < 2) And (Blocks_Per_Sheet > 1) Then Rot1 = True If (OFFALL2 < 2) And (Blanks_Per_Block > 1) Then Rot2 = True Denting% = 0 If (dim1! <= 4) And (dim1! >= 2) And Rot1 Then Blocks_Per_Sheet = Blocks_Per_Sheet - 1 Denting% = 1 End If If (dim2! <= 4) And (dim2! >= 2) And Rot2 Then Blanks_Per_Block = Blanks_Per_Block - 1 If Denting% = 1 Then Denting% = 3 Else Denting% = 2 End If End If parts_per_sheet = Blocks_Per_Sheet * Blanks_Per_Block * C% If parts_per_sheet <> 0 Then ' ' calculated GW ' Gw! = Sheet_Width! * Sheet_Length! / 144 * lb_per_sq_ft! / parts_per_sheet ' Gw! = (Int(Gw * 1000)) / 1000 Gw! = Val(Format(Gw!, "0.000")) Call CalcActualWt(dim1!, dim2!, Aw!) Aw! = Aw! / Parts_per_strip! Else If PurchaseBlank% Then If blankUnits$ = "LB" Then ' ' calculated GW ' Gw! = Sheet_Width! * Sheet_Length! / 144 * lb_per_sq_ft! ' Gw! = (Int(Gw * 1000)) / 1000 Gw! = Val(Format(Gw!, "0.000")) Else Gw! = 1 End If Aw! = Gw! parts_per_sheet = 1 Else RC% = 4 FirstCutDir% = 0 End If End If End Sub Sub CalcLaborCost(LaborTot!) Dim AddnlQDB As Database, AddnlQSet As Recordset PartN$ = currform![PartNumber] Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set search criteria. currform!txtCalcStat.Caption = "LC - Opening AddnlQ1" Set AddnlQDB = DBEngine.Workspaces(0).Databases(0) Set AddnlQSet = AddnlQDB.OpenRecordset("AddnlQ1", DB_OPEN_DYNASET) ' Create dynaset. 'Set AddnlQDB = stAddnlQSet 'Set AddnlQSet = stAddnlQSet AddnlQSet.FindFirst Criteria$ ' Find first occurrence. currform!txtCalcStat.Caption = "Calculating Labor Cost" LaborTot! = 0 Do Until AddnlQSet.NoMatch ' Loop until no matching records. Hopc$ = AddnlQSet!OpCode If InStr(Hopc$, "*") = 0 Then rs! = AddnlQSet!RunStd Lr! = AddnlQSet!LaborRate 'LaborTot! = LaborTot! + (rs! * Lr! * 2.56) 'Labor Rate has Full Burden LaborTot! = LaborTot! + (rs! * Lr!) End If AddnlQSet.FindNext Criteria$ ' Find next occurrence. DoEvents Loop ' End of loop. End Sub Sub CalcMultGrossWeight(dim1!, dim2!, Gw!, Aw!) Dim A!, b! ' 'Entered from user ' Part_Height ' Part_Width ' Bottom_Trim_Cut ' Top_Trim_Cut ' 'From material ' Sheet_Width ' Sheet_Length ' lb_per_sq_ft ' ' Blocks_Per_Sheet ' Blanks_Per_Block ' Parts_Per_Sheet ' d1! = dim1! d2! = Part_Width + Pt_Width! If (d1! = 0) Or (d2! = 0) Or (lb_per_sq_ft = 0) Then Exit Sub Call CalcActualWt(d1!, d2!, Aw!) If ExtraShear% Then A! = Int((Sheet_Length - Trim_Cut) / dim2!) Blocks_Per_Sheet! = Int(A!) Parts_Per_Block! = Int((Sheet_Width - TrimCut) / dim1!) Blanks_Per_Block! = Int((Sheet_Width - TrimCut) / dim1!) parts_per_sheet! = Blocks_Per_Sheet! * Parts_Per_Block! * Parts_Per_blank! Else A! = (Sheet_Length - Trim_Cut) / dim1! Blocks_Per_Sheet! = Int(A!) OFFALL1 = Sheet_Length! - Trim_Cut! - dim1! * Blocks_Per_Sheet! Rot1 = False If (OFFALL1 < 2) And (Blocks_Per_Sheet > 1) Then Rot1 = True If (dim1! <= 4) And (dim1! >= 2) And Rot1 Then Blocks_Per_Sheet! = Blocks_Per_Sheet! - 1 Denting% = 1 End If parts_per_sheet! = Blocks_Per_Sheet! * Parts_Per_blank! If (Multi$ = "LASER/SHEAR") Then Blanks_Per_Block = Int(Sheet_Width / dim2!) parts_per_sheet! = Blanks_Per_Block! * Blocks_Per_Sheet! * Parts_Per_blank! End If End If If parts_per_sheet! <> 0 Then Gw! = Sheet_Width * Sheet_Length / 144 * lb_per_sq_ft / parts_per_sheet ' Gw! = (Int(Gw! * 1000)) / 1000 Gw! = Val(Format(Gw!, "0.000")) Else If (First_Dim! = Sheet_Length!) And (Second_dim! = Sheet_Width!) Then ' ' calculated GW ' Gw! = Sheet_Width! * Sheet_Length! / 144 * lb_per_sq_ft! / Parts_Per_blank ' Gw! = (Int(Gw * 1000)) / 1000 Gw! = Val(Format(Gw!, "0.000")) pw! = ItsAZero!(Part_Width!) 'currform![PartWidth]) Aw! = Part_Height! * pw! / 144 * lb_per_sq_ft! Blocks_Per_Sheet! = 1 parts_per_sheet = Parts_Per_blank Else Gw! = 0 End If End If End Sub Sub calcs() Dim MachQDB As Database, MachQSet As Recordset Dim MachNQDB As Database, MachNQSet As Recordset 'Parting tool width = .2 Pt_Width! = 0.2: Trim_Cut = 0.1 Grain$ = Trim$(UCase$(currform![GrainDir])) MachinesWithShears$ = "C-3C-4C-5C-6C-7C-8C-9V-1V-2V-4C10" ' currform!lblXrefMessage.Visible = False ' ' Set XrefQDB = DBEngine.Workspaces(0).Databases(0) ' Set XrefQSet = XrefQDB.OpenRecordset("RMSFILES#_EGSSP1A0", DB_OPEN_DYNASET) ' Create dynaset. ' XrefQSet.MoveFirst ' PartN$ = currform![PartNumber] ' xPN$ = Left(PartN$, 7) ' Do Until XrefQSet.EOF ' If (Trim(XrefQSet!CURPN) = xPN$) Or (Trim(XrefQSet!NEWPN) = xPN$) Then ' ' currform!lblXrefMessage.Visible = True ' currform!lblXrefMessage.Caption = "This part has an associated part - " + Trim(XrefQSet!CURPN) + Right$(PartN, 1) + "/" + Trim(XrefQSet!NEWPN) + Right$(PartN, 1) ' currform!cmd300Series.Enabled = True ' ' Exit Do ' End If ' XrefQSet.MoveNext ' Loop wh$ = currform![Warehouse] whl$ = currform!Field113.Column(10) If wh$ = "90" Then If whl$ = "2" Then currform![CalculationStatus] = 11 Call ErrorMessages Exit Sub End If warehousewc$ = "302" Else If whl$ = "1" Then currform![CalculationStatus] = 11 Call ErrorMessages Exit Sub End If warehousewc$ = "347" End If GrNone% = currform![GrainNone] currform!cmdDeleteFileFromTrumpfs.Visible = False currform!lblCalcStat.Visible = True currform!txtCalcStat.Caption = "Calculations underway" currform!txtCalcStat.Visible = True currform!txtCalcStat2.Visible = True DoEvents OutPutData% = True If GrNone% Then GrNone% = False Grain$ = "ALONG FIRST" OutPutData% = False currform!txtCalcStat2.Caption = "Calculating along first dimension" DoEvents GoSub CalcPart prc1 = currform![PartCost] GrNone% = False Grain$ = "ALONG SECOND" OutPutData% = True currform!txtCalcStat2.Caption = "Calculating along Second dimension" DoEvents GoSub CalcPart prc2 = currform![PartCost] Debug.Print prc1, prc2 If prc1 < prc2 Then currform!GrainDir = "Along First Dimension" ElseIf prc1 > prc2 Then currform!GrainDir = "Along Second Dimension" Else If First_Dim! < Second_dim! Then currform!GrainDir = "Along First Dimension" Else currform!GrainDir = "Along Second Dimension" End If End If Call GrainFromRec If currform!GrainDir <> "Along Second Dimension" Then Grain$ = currform!GrainDir GrNone% = False OutPutData% = True currform!txtCalcStat2.Caption = "Calculating along chosen dimension" DoEvents GoSub CalcPart GrNone% = True End If Else currform!txtCalcStat2.Caption = "Calculating along only dimension" GoSub CalcPart End If currform!cmdDeleteFileFromTrumpfs.Visible = True currform!lblCalcStat.Visible = False currform!txtCalcStat.Visible = False currform!txtCalcStat2.Visible = False Exit Sub CalcPart: currform![GrossWt] = 0 currform![ActualWt] = 0 currform![Utilization] = 0 currform![PartsPerSheet] = 0 currform![BlocksPerSheet] = 0 currform![BlanksPerBlock] = 0 currform![ActualPartHeight] = 0 currform![ActualPartWidth] = 0 currform![SheetSize] = " " currform![BlankSize] = " " currform![PartSize] = " " DSF$ = UCase$(itsaNull$(currform![DatasheetFlag])) If DSF$ = "NONE" Then NoDataSheets% = 0 ElseIf DSF$ = "REQ'D" Then NoDataSheets% = 1 Else NoDataSheets% = 2 End If currform![CalculationStatus] = 0 First_Dim! = ItsAZero!(currform![FirstDim]) Second_dim! = ItsAZero!(currform![SecDim]) Denting% = 0 Parts_Per_blank! = ItsAZero!(currform![PartsPerBlank]) Part_Height! = ItsAZero!(currform![PartHeight]) Bottom_Trim_Cut! = ItsAZero!(currform![BotTrimCut]) TOP_TRIM_CUT! = ItsAZero!(currform![TopTrimCut]) Part_Width! = ItsAZero!(currform![PartWidth]) Gp$ = currform!Field113.Column(1) Gauge$ = Gp$ Multi$ = Trim$(UCase$(currform![CutType])) TypeDeburr$ = Trim$(UCase$(currform![Deburr])) ' ' ROTATE SHEET FOR BLANKS -- 12-NOV-09 ' ' ---------------------------------------------------------- Sheet_Width! = ItsAZero!(currform!Field113.Column(4)) Sheet_Length! = ItsAZero!(currform!Field113.Column(3)) RotateBlank = ItsAZero!(currform![GrainShear]) If (Multi$ <> "NO CNC") And (Multi$ <> "BLANK") Then RotateBlank = 0 End If If RotateBlank <> 0 Then Sheet_Width! = ItsAZero!(currform!Field113.Column(3)) Sheet_Length! = ItsAZero!(currform!Field113.Column(4)) End If ' ---------------------------------------------------------- ' 'Density Change ' lb_per_sq_ft! = ItsAZero!(currform!Field113.Column(5)) ' ' ' Location% = ItsAZero!(currform!Field113.Column(6)) PricePerLB! = ItsAZero!(currform!Field113.Column(8)) PurchaseBlank% = ItsAZero!(currform!Field113.Column(9)) blankUnits$ = itsaNull$(currform!Field113.Column(11)) MetalName$ = currform!Field113.Column(0) MetalPart$ = currform!Field113.Column(2) PunchDieDescr$ = currform!PunchDie PunchCounter% = Val(itsaNull$(currform!PunchCount)) PunchPresserOptions% = currform!PunchPressOption If currform!GrainShearChk.Visible Then ExtraShear% = currform![GrainShear] Else ExtraShear% = False End If PartN$ = currform![PartNumber] ' 'insert check on primary CNC ' Set MachQDB = DBEngine.Workspaces(0).Databases(0) Set MachQSet = MachQDB.OpenRecordset("MachinesQ1", DB_OPEN_DYNASET) ' Create dynaset. Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set search criteria. PMachine$ = "" MachQSet.FindFirst Criteria$ ' Find first occurrence. currform!txtCalcStat.Caption = "MP - look for primary machine" Do Until MachQSet.NoMatch ' Loop until no matching records. If MachQSet!Prime = True Then If MachQSet!Tool <> "SHR" Then If PMachine$ <> "" Then currform![CalculationStatus] = 16 Call ErrorMessages Exit Sub End If PMachine$ = MachQSet!MachineName PWC1$ = MachQSet!Tool PCTime! = MachQSet!CycleTime End If End If MachQSet.FindNext Criteria$ ' Find next occurrence. DoEvents Loop If (PMachine$ = "") And (Multi$ <> "NO CNC") And (Multi$ <> "BLANK") Then currform![CalculationStatus] = 15 Call ErrorMessages Exit Sub End If ' ' ' Call Elem_ClearAllRecs(PartN$) If Val(itsaNull$(currform!Field113.Column(7))) <> 0 Then alt = 1 Else alt = 0 End If If (First_Dim! = 0) Or (Second_dim! = 0) Or (lb_per_sq_ft! = 0) Then currform![CalculationStatus] = 6 Call ErrorMessages Exit Sub End If If ((Multi$ = "MULTIPLE") Or (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "SLUG") Or (Multi$ = "LASER/SHEAR")) And (Parts_Per_blank! = 0) Then currform![CalculationStatus] = 6 Call ErrorMessages Exit Sub End If If (Multi$ = "BLANK") Then If (Second_dim! > Sheet_Width!) Then currform![CalculationStatus] = 2 Call ErrorMessages Exit Sub End If End If If (Multi$ = "MULTIPLE") And (Part_Width! = 0) Then currform![CalculationStatus] = 10 Call ErrorMessages Exit Sub End If If (Bottom_Trim_Cut! < 2) And (Multi$ = "MULTIPLE") Then currform![CalculationStatus] = 5 Call ErrorMessages Exit Sub End If If Multi$ = "LASER" Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then Part_Width! = (Sheet_Width! / Parts_Per_blank) - Pt_Width! Bottom_Trim_Cut! = 0 TOP_TRIM_CUT! = 0 If (Multi$ = "LASER/SHEAR") Then Part_Width! = (Second_dim! / Parts_Per_blank) - Pt_Width! End If End If Celltype$ = UCase$(currform![CellDeburrTypes]) MetalName$ = UCase(currform!Field113.Column(0)) If Celltype = "TIME SAVER" Then If ((Not (InStr(MetalName$, "COLD ROLL") = 0) And (Not (InStr(MetalName$, "S/S") = 0)))) Then ' aluminized currform![CalculationStatus] = 19 Call ErrorMessages Exit Sub End If End If If Multi$ <> "BLANK" Then Calcerr0% = currform![CalculationStatus] GoSub CalcMaterialWt calcerr1% = currform![CalculationStatus] aw1! = Gw! aw2! = 0 If alt = 1 And Multi$ <> "MULTIPLE" Then currentMetal$ = currform![MetalType] currform![MetalType] = itsaNull$(currform!Field113.Column(7)) ' ' ROTATE SHEET FOR BLANKS -- 12-NOV-09 ' ' ---------------------------------------------------------- Sheet_Width! = ItsAZero!(currform!Field113.Column(4)) Sheet_Length! = ItsAZero!(currform!Field113.Column(3)) RotateBlank = ItsAZero!(currform![GrainShear]) If (Multi$ <> "NO CNC") And (Multi$ <> "BLANK") Then RotateBlank = 0 End If If RotateBlank <> 0 Then Sheet_Width! = ItsAZero!(currform!Field113.Column(3)) Sheet_Length! = ItsAZero!(currform!Field113.Column(4)) End If ' ---------------------------------------------------------- ' 'Density Change ' lb_per_sq_ft! = ItsAZero!(currform!Field113.Column(5)) ' ' ' Location% = ItsAZero!(currform!Field113.Column(6)) PricePerLB! = ItsAZero!(currform!Field113.Column(8)) PurchaseBlank% = ItsAZero!(currform!Field113.Column(9)) currform![CalculationStatus] = Calcerr0% GoSub CalcMaterialWt calcerr2% = currform![CalculationStatus] aw2! = Gw! If (((aw1! <= aw2!) And (calcerr1% = 0)) Or (calcerr2% <> 0) Or (aw2! = 0)) Then currform![MetalType] = currentMetal$ ' ' ROTATE SHEET FOR BLANKS -- 12-NOV-09 ' ' ---------------------------------------------------------- Sheet_Width! = ItsAZero!(currform!Field113.Column(4)) Sheet_Length! = ItsAZero!(currform!Field113.Column(3)) RotateBlank = ItsAZero!(currform![GrainShear]) If (Multi$ <> "NO CNC") And (Multi$ <> "BLANK") Then RotateBlank = 0 End If If RotateBlank <> 0 Then Sheet_Width! = ItsAZero!(currform!Field113.Column(3)) Sheet_Length! = ItsAZero!(currform!Field113.Column(4)) End If ' ---------------------------------------------------------- ' 'Density Change ' lb_per_sq_ft! = ItsAZero!(currform!Field113.Column(5)) ' ' ' Location% = ItsAZero!(currform!Field113.Column(6)) PricePerLB! = ItsAZero!(currform!Field113.Column(8)) PurchaseBlank% = ItsAZero!(currform!Field113.Column(9)) currform![CalculationStatus] = Calcerr0% GoSub CalcMaterialWt End If End If End If If currform![CalculationStatus] = 0 Then GoSub DoAnswers If Celltype = "TIME SAVER" Then If ((currform!ActualPartHeight < 5) And (currform!ActualPartWidth < 5)) Then ' too small for time saver currform![CalculationStatus] = 20 Call ErrorMessages Exit Sub End If End If If ((Bottom_Trim_Cut! < 2) Or (Bottom_Trim_Cut! >= FirstCut) Or (TOP_TRIM_CUT! >= FirstCut)) And (Multi$ = "MULTIPLE") Then currform![CalculationStatus] = 5 Call ErrorMessages Exit Sub End If CalculatedGrossWeight! = Gw! Call MakeProcesses GoSub CalcPrice Call PurgeCNCs End If Blank_wt = First_Dim! * Second_dim! / 144 * lb_per_sq_ft! If Blank_wt > 50 Then currform!WeightWarn.Visible = True currform!WeightWarn.Caption = "Warning Blank Weight of " + Format(Blank_wt, "0") + "lbs. exceeded maximum." End If Return Exit Sub DoAnswers: If Multi$ = "BLANK" Then FirstCutDir% = 1 Select Case FirstCutDir% Case 1 If (Multi$ = "MULTIPLE") Or (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then Call CalcMultGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!) If (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then currform![ActualPartHeight] = currform![PartHeight] currform![ActualPartWidth] = currform![PartWidth] Else currform![ActualPartHeight] = First_Dim! - TOP_TRIM_CUT! - Bottom_Trim_Cut! currform![ActualPartWidth] = currform![PartWidth] End If Else Call CalcGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!, RC%) If RC% <> 0 Then currform![CalculationStatus] = RC% Call ErrorMessages End If currform![ActualPartHeight] = First_Dim! currform![ActualPartWidth] = Second_dim! End If If (Multi$ <> "LASER") And (Multi$ <> "SALVAGNINI") And (Multi$ <> "LASER/SHEAR") Or (Multi$ = "SLUG") Then currform![PartHeight] = First_Dim! End If FirstCut! = First_Dim! SecondCut! = Second_dim! If ExtraShear% Then fc$ = "Along Second Dimension" currform!GrDirOpt = 2 Else fc$ = "Along First Dimension" currform!GrDirOpt = 1 End If Case 2 Call CalcGrossWeight(Second_dim!, First_Dim!, Gw!, Aw!, RC%) If RC% <> 0 Then currform![CalculationStatus] = RC% Call ErrorMessages End If fc$ = "Along Second Dimension" currform!GrDirOpt = 2 If (Multi$ <> "LASER") And (Multi$ <> "SALVAGNINI") And (Multi$ <> "LASER/SHEAR") Or (Multi$ = "SLUG") Then currform![PartHeight] = Second_dim! End If currform![ActualPartHeight] = Second_dim! currform![ActualPartWidth] = First_Dim! FirstCut! = Second_dim! SecondCut! = First_Dim! Case Else fc$ = currform![GrainDir] currform![PartHeight] = First_Dim! currform![ActualPartHeight] = First_Dim! currform![ActualPartWidth] = Second_dim! FirstCut! = First_Dim! SecondCut! = Second_dim! If Multi$ = "BLANK" Then FirstCutDir% = 1 End Select Actual_PartHeight = currform![ActualPartHeight] Actual_PartWidth = currform![ActualPartWidth] If (currform![ActualPartHeight] >= 19) Or (currform![ActualPartWidth] >= 19) Then currform![CellDeburrTypes] = "Hand Deburr" Celltype$ = UCase$(currform![CellDeburrTypes]) End If '##################33 If FirstCutDir% = 0 Then currform![CalculationStatus] = 1 Else Call CalcActualWt(Actual_PartHeight!, Actual_PartWidth!, Aw!) 'per Rick Bergeson 10-Oct-2006 currform![GrainDir] = fc$ If Aw! > Gw! Then Aw! = Gw! currform![GrossWt] = Gw! currform![ActualWt] = Aw! currform![Utilization] = 0 If Gw! <> 0 Then currform![Utilization] = Aw! / Gw! End If currform![PartsPerSheet] = parts_per_sheet! currform![BlocksPerSheet] = Blocks_Per_Sheet! currform![BlanksPerBlock] = Blanks_Per_Block! currform![SheetSize] = Format$(Sheet_Width!, "###0.000") + " X " + Format$(Sheet_Length!, "###0.000") If (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then currform![PartSize] = Format$(currform![PartHeight], "###0.000") + " X " + Format$(currform![PartWidth], "###0.000") Else currform![PartSize] = Format$(currform![ActualPartHeight], "###0.000") + " X " + Format$(currform![ActualPartWidth], "###0.000") End If currform![BlankSize] = Format$(First_Dim!, "###0.000") + " X " + Format$(Second_dim!, "###0.000") End If Call ErrorMessages Return CalcPrice: ' ' Cost Calculations ' Call CalcLaborCost(LaborTot!) If PurchaseBlank% Then currform![MaterialCost] = Val(Format(PricePerLB!, "#####0.####")) Else currform![MaterialCost] = Val(Format(Gw! * PricePerLB!, "#####0.####")) End If currform![LaborCost] = Val(Format(LaborTot!, "#####0.####")) currform![PartCost] = currform![MaterialCost] + currform![LaborCost] Debug.Print currform![MaterialCost], currform![LaborCost], currform![PartCost] Return CalcMaterialWt: If (Multi$ = "NO CNC") And (Punch$ <> "!NONE!") And (currform!PunchPressOption = 2) And (Sheet_Width <> Second_dim!) Then currform![CalculationStatus] = 2 FirstCutDir% = 0 End If If (Multi$ = "MULTIPLE") Or (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then If (Sheet_Width <> Second_dim!) And (Not (ExtraShear%)) And (Multi$ <> "LASER/SHEAR") Then currform![CalculationStatus] = 2 FirstCutDir% = 0 ElseIf (((PartWidth + Pt_Width) * Parts_Per_blank) - Pt_Width > Sheet_Width) And (Multi$ <> "LASER") And (Multi$ <> "SALVAGNINI") And (Multi$ <> "SLUG") And (Multi$ <> "LASER/SHEAR") Then currform![CalculationStatus] = 3 FirstCutDir% = 0 ElseIf (Bottom_Trim_Cut! < 2) And (Multi$ <> "LASER") And (Multi$ <> "SALVAGNINI") And (Multi$ <> "SLUG") And (Multi$ <> "LASER/SHEAR") Then currform![CalculationStatus] = 5 FirstCutDir% = 0 Else Call CalcMultGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!) FirstCutDir% = 1 End If Else If Not (GrNone%) Then If Left$(Grain$, 11) = "ALONG FIRST" Then FirstCutDir% = 1 Call CalcGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!, RC%) If RC% <> 0 Then currform![CalculationStatus] = RC% Call ErrorMessages End If Else FirstCutDir% = 2 Call CalcGrossWeight(Second_dim!, First_Dim!, Gw!, Aw!, RC%) If RC% <> 0 Then currform![CalculationStatus] = RC% Call ErrorMessages End If End If Else Call CalcGrossWeight(First_Dim!, Second_dim!, Gw1!, Aw!, RC%) If RC% <> 0 Then currform![CalculationStatus] = RC% Call ErrorMessages End If Call CalcGrossWeight(Second_dim!, First_Dim!, Gw2!, Aw!, RC%) If RC% <> 0 Then currform![CalculationStatus] = RC% Call ErrorMessages End If If Gw1! < Gw2! Then FirstCutDir% = 1 Call CalcGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!, RC%) If RC% <> 0 Then currform![CalculationStatus] = RC% Call ErrorMessages End If Else FirstCutDir% = 2 Call CalcGrossWeight(Second_dim!, First_Dim!, Gw!, Aw!, RC%) If RC% <> 0 Then currform![CalculationStatus] = RC% Call ErrorMessages End If End If If Gw1! = Gw2! Then If First_Dim! < Second_dim! Then FirstCutDir% = 1 Call CalcGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!, RC%) If RC% <> 0 Then currform![CalculationStatus] = RC% Call ErrorMessages End If Else FirstCutDir% = 2 Call CalcGrossWeight(Second_dim!, First_Dim!, Gw!, Aw!, RC%) If RC% <> 0 Then currform![CalculationStatus] = RC% Call ErrorMessages End If End If End If End If End If Call ErrorMessages Return End Sub Sub Calculate_All() Dim MainDB As Database, MainSet As Recordset Dim MainTableDef As TableDef Dim DocName As String Dim LinkCriteria As String Dim MyForm As Form Set MainDB = DBEngine.Workspaces(0).Databases(0) currform.Refresh PN$ = currform!PartNumber End Sub Sub Calculate_Button() On Error GoTo Bad_Record DoCmd.Hourglass True If Trim$(currform!PartNumber) <> "" Then On Error GoTo NoMaterialSelected Gp$ = currform!Field113.Column(1) On Error GoTo NoCutType Multi$ = Trim$(UCase$(currform![CutType])) On Error GoTo NoDeburr TypeDeburr$ = Trim$(UCase$(currform![Deburr])) On Error GoTo NoFirstDim f! = currform![FirstDim] On Error GoTo 0 Call calcs End If On Error GoTo 0 DoCmd.Hourglass False Exit Sub NoMaterialSelected: currform![CalculationStatus] = 11 Resume Done NoFirstDim: currform![CalculationStatus] = 12 Resume Done NoCutType: currform![CalculationStatus] = 13 Resume Done NoDeburr: currform![CalculationStatus] = 14 Resume Done Bad_Record: currform![CalculationStatus] = 7 Resume Done Resume Next Resume Done: Call ErrorMessages On Error GoTo 0 End Sub Function CalculateRec() Call Calculate_All End Function Sub CheckGrainShear() M$ = itsaNull$(currform.CutType) MN$ = itsaNull$(currform!Field113.Column(0)) If (M$ = "MULTIPLE") Or (M$ = "LASER") Or (M$ = "SALVAGNINI") Or (M$ = "LASER/SHEAR") Or (M$ = "SLUG") Then If InStr(MN$, "S/S") <> 0 Then currform!GrainShearChk.Visible = True If currform!GrainShearChk Then currform!Text239.Visible = True ' parts per blank currform!Field238.Visible = True ' parts per blank currform!Text147.Visible = True ' blanks per block currform!BlanksPerBlock.Visible = True ' blanks per block End If Else currform!GrainShearChk.Visible = False End If Else currform!GrainShearChk.Visible = False End If End Sub Sub ckPrimaryScreen() If PrimaryScreen$ = "" Then PrimaryScreen$ = "14" + Chr$(34) + " Process Sheet" If Left$(Initforms$, 2) = "14" Then DocName$ = "14" + Chr$(34) + " Process Sheet" Else DocName$ = "Process Sheet" End If PrimaryScreen$ = DocName$ End If End Sub Sub CNC_Verbage(DbSel%, vb$) Select Case DbSel% Case 1 ' 123456789012345678901234567890123456789 If AddnlHandDeburr!() = 0 Then vb$ = "NOTCH, PIERCE, & HAND DEBURR (3) EDGES " If TOP_TRIM_CUT! <> 0 Then vb$ = "NOTCH, PIERCE, & HAND DEBURR (2) EDGES " End If Else vb$ = "NOTCH, PIERCE, & HAND DEBURR (3) EDGES " If TOP_TRIM_CUT! <> 0 Then vb$ = "NOTCH, PIERCE, & HAND DEBURR (2) EDGES " End If vb$ = vb$ + " INCLUDING INTERNAL CUTOUTS " Call ds_add("HANDDEBURR", "AEdg") End If Call ds_add("HANDDEBURR", "MEdg") Case 2 If (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then slugispart% = False prm$ = Left$(PMachine$, 3) Select Case prm$ Case "C-1", "C-2", "C-3", "C-4", "C-5", "C-6", "C-7", "C-8", "C-9", "V-1", "V-2", "V-4", "C10" vb$ = "NOTCH, PIERCE, & DEBURR USING " vb$ = vb$ + "TIMESAVER " slugispart% = True Case Else vb$ = "CUT COMPLETE & DEBURR USING TIMESAVER " End Select If (Multi$ = "SLUG") Then slugispart% = True Else vb$ = "NOTCH, PIERCE, & DEBURR USING " vb$ = vb$ + "TIMESAVER " End If Call ds_add("TIMESAVER", "SHRD") Case 3 If AddnlHandDeburr!() = 0 Then vb$ = "NOTCH, PIERCE, HAND DEBURR (3) EDGES, " vb$ = vb$ + "SHEAR & HAND DEBURR (1) EDGE " Else vb$ = "NOTCH, PIERCE, HAND DEBURR (3) EDGES " vb$ = vb$ + "INCLUDING INTERNAL CUTOUTS, SHEAR & " vb$ = vb$ + "HAND DEBURR (1) EDGE " Call ds_add("HANDDEBURR", "AEdg") End If Call Add_Shear_Verbage(vb$) Call ds_add("HANDDEBURR", "1Edg") Call ds_add("HANDDEBURR", "MEdg") Call ds_add("MULTSHEAR", "CONT") Case 4 If AddnlHandDeburr!() = 0 Then vb$ = "NOTCH, PIERCE, HAND DEBURR (2) EDGES, " vb$ = vb$ + "SHEAR, & HAND DEBURR (2) EDGES " Else vb$ = "NOTCH, PIERCE, HAND DEBURR (2) EDGES " vb$ = vb$ + "INCLUDING INTERNAL CUTOUTS, SHEAR, & " vb$ = vb$ + "HAND DEBURR (2) EDGES " Call ds_add("HANDDEBURR", "AEdg") End If Call Add_Shear_Verbage(vb$) Call ds_add("HANDDEBURR", "2Edg") Call ds_add("HANDDEBURR", "MEdg") Call ds_add("MULTSHEAR", "CONT") Case 5 If AddnlHandDeburr!() = 0 Then vb$ = "NOTCH, PIERCE, HAND DEBURR (3) EDGES, " vb$ = vb$ + "SHEAR, & DEBURR (1) EDGE USING " vb$ = vb$ + "PEDESTAL GRINDER " Else vb$ = "NOTCH, PIERCE, HAND DEBURR (3) EDGES, " vb$ = vb$ + "SHEAR, & DEBURR (1) EDGE USING " vb$ = vb$ + "PEDESTAL GRINDER " Call ds_add("HANDDEBURR", "AEdg") End If Call Add_Shear_Verbage(vb$) Call ds_add("HANDDEBURR", "MEdg") Call ds_add("PEDESTAL", "1Edg") Call ds_add("MULTSHEAR", "CONT") Case 6 If AddnlHandDeburr!() = 0 Then vb$ = "NOTCH, PIERCE, HAND DEBURR (2) EDGES, " vb$ = vb$ + " SHEAR, & DEBURR (2) EDGES USING " vb$ = vb$ + " PEDESTAL GRINDER " Else vb$ = "NOTCH, PIERCE, HAND DEBURR (2) EDGES, " vb$ = vb$ + " SHEAR, & DEBURR (2) EDGES USING " vb$ = vb$ + " PEDESTAL GRINDER " Call ds_add("HANDDEBURR", "AEdg") End If Call Add_Shear_Verbage(vb$) Call ds_add("HANDDEBURR", "MEdg") Call ds_add("PEDESTAL", "2Edg") Call ds_add("MULTSHEAR", "CONT") Case 7 vb$ = "NOTCH, PIERCE, HAND DEBURR, SHEAR, & " vb$ = vb$ + "DEBURR USING TIMESAVER " Call Add_Shear_Verbage(vb$) Call ds_add("HANDDEBURR", "MEdg") Call ds_add("TIMESAVER", "SHRD") Call ds_add("MULTSHEAR", "T/S ") Case 8 If AddnlHandDeburr!() = 0 Then vb$ = "NOTCH, PIERCE, SHEAR, & HAND DEBURR " vb$ = vb$ + "ALL EDGES " Else vb$ = "NOTCH, PIERCE, SHEAR, & HAND DEBURR " vb$ = vb$ + "ALL EDGES INCLUDING INTERNAL CUTOUTS " Call ds_add("HANDDEBURR", "AEdg") End If Call Add_Shear_Verbage(vb$) Call ds_add("HANDDEBURR", "4Edg") Call ds_add("MULTSHEAR", "CONT") Case 9 If AddnlHandDeburr!() = 0 Then vb$ = "NOTCH, PIERCE, SHEAR & DEBURR ALL " vb$ = vb$ + "EDGES USING PEDESTAL GRINDER " Else vb$ = "NOTCH, PIERCE, SHEAR, HAND DEBURR " vb$ = vb$ + "INSIDE CUTOUTS, & DEBURR EDGES USING " vb$ = vb$ + "PEDESTAL GRINDER " Call ds_add("HANDDEBURR", "AEdg") End If Call Add_Shear_Verbage(vb$) Call ds_add("PEDESTAL", "4Edg") Call ds_add("MULTSHEAR", "CONT") Case 10 vb$ = "NOTCH, PIERCE, SHEAR & DEBURR USING " vb$ = vb$ + "TIMESAVER " Call ds_add("TIMESAVER", "SHRD") Call ds_add("MULTSHEAR", "T/S ") Call Add_Shear_Verbage(vb$) Case 11 If (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then slugispart% = False prm$ = Left$(PMachine$, 3) Select Case prm$ Case "C-1", "C-2", "C-3", "C-4", "C-5", "C-6", "C-7", "C-8", "C-9", "V-1", "V-2", "V-4", "C10" If AddnlHandDeburr!() = 0 Then vb$ = "NOTCH, PIERCE, & HAND DEBURR ALL " vb$ = vb$ + "EDGES " Else vb$ = "NOTCH, PIERCE, & HAND DEBURR ALL " vb$ = vb$ + "EDGES INCLUDING INTERNAL CUTOUTS " Call ds_add("HANDDEBURR", "AEdg") End If slugispart% = True Case Else If AddnlHandDeburr!() = 0 Then vb$ = "CUT COMPLETE & HAND DEBURR ALL EDGES " Else vb$ = "CUT COMPLETE & HAND DEBURR ALL EDGES " vb$ = vb$ + "INCLUDING INTERNAL CUTOUTS " Call ds_add("HANDDEBURR", "AEdg") End If End Select If (Multi$ = "SLUG") Then slugispart% = True Else If AddnlHandDeburr!() = 0 Then vb$ = "NOTCH, PIERCE, & HAND DEBURR ALL " vb$ = vb$ + "EDGES " Else '123456789012345678901234567890123456789" vb$ = "NOTCH, PIERCE, & HAND DEBURR ALL " vb$ = vb$ + "EDGES INCLUDING INTERNAL CUTOUTS " Call ds_add("HANDDEBURR", "AEdg") End If End If Call ds_add("HANDDEBURR", "4Edg") Case 12 If AddnlHandDeburr!() = 0 Then vb$ = "NOTCH, PIERCE, & DEBURR ALL EDGES " vb$ = vb$ + "USING PEDESTAL GRINDER " Else vb$ = "NOTCH, PIERCE, HAND DEBURR INTERNAL " vb$ = vb$ + "CUTOUTS, & DEBURR ALL EDGES USING " vb$ = vb$ + "PEDESTAL GRINDER " Call ds_add("HANDDEBURR", "AEdg") End If Call ds_add("PEDESTAL", "4Edg") Case 13 If AddnlHandDeburr!() = 0 Then vb$ = "NOTCH, PIERCE, HAND DEBURR (3) EDGES, " If TOP_TRIM_CUT! <> 0 Then vb$ = "NOTCH, PIERCE, HAND DEBURR (2) EDGES, " End If vb$ = vb$ + "& SHEAR " Else vb$ = "NOTCH, PIERCE, HAND DEBURR (3) EDGES " If TOP_TRIM_CUT! <> 0 Then vb$ = "NOTCH, PIERCE, HAND DEBURR (2) EDGES " End If vb$ = vb$ + "INCLUDING INTERNAL CUTOUTS, & SHEAR " Call ds_add("HANDDEBURR", "AEdg") End If Call Add_Shear_Verbage(vb$) Call ds_add("HANDDEBURR", "MEdg") Call ds_add("MULTSHEAR", "CONT") Case 14 vb$ = "NOTCH, PIERCE, & SHEAR " Call Add_Shear_Verbage(vb$) Call ds_add("MULTSHEAR", "CONT") Case 15 vb$ = "NOTCH, PIERCE, & DEBURR USING " vb$ = vb$ + "TIMESAVER " Call ds_add("TIMESAVER", "MULT") Case 16 vb$ = "NOTCH, PIERCE, DEBURR USING TIMESAVER, " vb$ = vb$ + " & SHEAR " Call Add_Shear_Verbage(vb$) Call ds_add("TIMESAVER", "MULT") Call ds_add("MULTSHEAR", "T/S ") Case Else vb$ = "" End Select Exit Sub End Sub Sub CutTypeFormSettings() Select Case currform.CutType Case "Single", "Single/Shear" currform!chkRotateBlank.Visible = False currform!lblRotateBlank.Visible = False currform!PartsPerBlank.Visible = False currform!BotTrimCut.Visible = False currform!TopTrimCut.Visible = False currform!PartWidth.Visible = False currform!SubForm2.Visible = True currform!Button200.Visible = True currform!CalcCNCtape.Visible = True currform!Text232.Visible = False currform!EntPartHeight.Visible = False currform!Text239.Visible = False ' parts per blank currform!Field238.Visible = False ' parts per blank currform!Text147.Visible = True ' blanks per block currform!BlanksPerBlock.Visible = True ' blanks per block Case "Multiple" currform!chkRotateBlank.Visible = False currform!lblRotateBlank.Visible = False currform!PartsPerBlank.Visible = True currform!BotTrimCut.Visible = True currform!PartWidth.Visible = True currform!TopTrimCut.Visible = True currform!SubForm2.Visible = True currform!Button200.Visible = True currform!CalcCNCtape.Visible = True currform!Text232.Visible = False currform!EntPartHeight.Visible = False currform!Text239.Visible = True ' parts per blank currform!Field238.Visible = True ' parts per blank currform!Text147.Visible = False ' blanks per block currform!BlanksPerBlock.Visible = False ' blanks per block Case "Laser", "Laser/Shear", "Slug", "Salvagnini" currform!chkRotateBlank.Visible = False currform!lblRotateBlank.Visible = False currform!PartsPerBlank.Visible = True currform!BotTrimCut.Visible = False currform!PartWidth.Visible = True currform!TopTrimCut.Visible = False currform!SubForm2.Visible = True currform!Button200.Visible = True currform!CalcCNCtape.Visible = True currform!Text232.Visible = True currform!EntPartHeight.Visible = True currform!Text239.Visible = True ' parts per blank currform!Field238.Visible = True ' parts per blank currform!Text147.Visible = False ' blanks per block currform!BlanksPerBlock.Visible = False ' blanks per block If currform.CutType = "Laser/Shear" Then currform!Text147.Visible = True ' blanks per block currform!BlanksPerBlock.Visible = True ' blanks per block End If Case "No CNC" currform!chkRotateBlank.Visible = True currform!lblRotateBlank.Visible = True currform!PartsPerBlank.Visible = False currform!BotTrimCut.Visible = False currform!TopTrimCut.Visible = False currform!PartWidth.Visible = False currform!SubForm2.Visible = False currform!Button200.Visible = False currform!CalcCNCtape.Visible = False currform!Text232.Visible = False currform!EntPartHeight.Visible = False currform!Text239.Visible = False ' parts per blank currform!Field238.Visible = False ' parts per blank currform!Text147.Visible = True ' blanks per block currform!BlanksPerBlock.Visible = True ' blanks per block Case "Blank" currform!chkRotateBlank.Visible = True currform!lblRotateBlank.Visible = True currform!PartsPerBlank.Visible = False currform!BotTrimCut.Visible = False currform!TopTrimCut.Visible = False currform!PartWidth.Visible = False currform!SubForm2.Visible = False currform!Button200.Visible = False currform!CalcCNCtape.Visible = False currform!Text232.Visible = False currform!EntPartHeight.Visible = False currform!Text239.Visible = False ' parts per blank currform!Field238.Visible = False ' parts per blank currform!Text147.Visible = False ' blanks per block currform!BlanksPerBlock.Visible = False ' blanks per block Case Else currform!chkRotateBlank.Visible = False currform!lblRotateBlank.Visible = False currform!PartsPerBlank.Visible = False currform!BotTrimCut.Visible = False currform!TopTrimCut.Visible = False currform!PartWidth.Visible = False currform!SubForm2.Visible = False currform!Button200.Visible = False currform!CalcCNCtape.Visible = False currform!Text232.Visible = False currform!EntPartHeight.Visible = False currform!Text239.Visible = False ' parts per blank currform!Field238.Visible = False ' parts per blank currform!Text147.Visible = False ' blanks per block currform!BlanksPerBlock.Visible = False ' blanks per block currform![CalculationStatus] = 9 End Select currform!MaterialInfo.Caption = itsaNull$(currform!Field113.Column(1)) + " - " + itsaNull$(currform!Field113.Column(2)) + " - Warehouse " + itsaNull$(currform!Field113.Column(10)) currform!WeightWarn.Visible = False Call CheckGrainShear Call PunchPressOptions End Sub Sub Delete_Part() Dim MainDB As Database, MainSet As Recordset Dim Main2DB As Database, Main2Set As Recordset Dim MachNamesDB As Database, MachNamesSet As Recordset Dim MachQDB As Database, MachQSet As Recordset Dim MainTableDef As TableDef Dim DocName As String Dim LinkCriteria As String Dim MyForm As Form Set MainDB = DBEngine.Workspaces(0).Databases(0) Set Main2DB = DBEngine.Workspaces(0).Databases(0) Set MachNamesDB = DBEngine.Workspaces(0).Databases(0) Set MachQDB = DBEngine.Workspaces(0).Databases(0) currform.Refresh PN$ = currform!PartNumber GoSub OPEN_Machs GoSub DeleteEm GoSub OPEN_Addnl GoSub DeleteEm GoSub Open_Data GoSub DeleteEm GoSub OPEN_Press GoSub DeleteEm GoSub Open_Mains MainSet.Seek ">=", PN$ If Not (MainSet.NoMatch) Then MainSet.MovePrevious If Not (MainSet.BOF) Then px$ = MainSet!PartNumber End If End If GoSub DeleteEm MainSet.MoveFirst currform.Requery Exit Sub DeleteEm: MainSet.Seek ">=", PN$ If Not (MainSet.NoMatch) Then Do While Trim$(MainSet!PartNumber) = PN$ MainSet.Delete MainSet.MoveNext If (MainSet.EOF) Then Exit Do Loop End If Return Open_Mains: Set MainSet = MainDB.OpenRecordset("Process", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("Process", DB_OPEN_TABLE) ' Create dynaset. ' Set mainset = StMainSet ' Set main2Set = StMainSet MainSet.Index = "PrimaryKey" Main2Set.Index = "PrimaryKey" Return OPEN_Addnl: Set MainSet = MainDB.OpenRecordset("AddnlProc", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("AddnlProc", DB_OPEN_TABLE) ' Create dynaset. ' Set mainset = StAddnlSet ' Set main2Set = StAddnlSet MainSet.Index = "PartNumber" Main2Set.Index = "PartNumber" Return OPEN_Machs: Set MainSet = MainDB.OpenRecordset("Machines", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("Machines", DB_OPEN_TABLE) ' Create dynaset. ' Set mainset = StMachQSet ' Set main2Set = StMachQSet MainSet.Index = "PartNumber" Main2Set.Index = "PartNumber" Return Open_Data: Set MainSet = MainDB.OpenRecordset("DataSheet", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("DataSheet", DB_OPEN_TABLE) ' Create dynaset. MainSet.Index = "PartNumber" Main2Set.Index = "PartNumber" Return OPEN_Press: Set MainSet = MainDB.OpenRecordset("PressBrakeOps", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("PressBrakeOps", DB_OPEN_TABLE) ' Create dynaset. ' Set mainset = StPressOpsSet ' Set main2Set = StPressOpsSet MainSet.Index = "PartNumber" Main2Set.Index = "PartNumber" Return End Sub Sub Det_CNC_Highest_Runtime(PartN$, CNC_Highest_RunTime!, REPOSITION_FLAG$) Dim MachQDB As Database, MachQSet As Recordset Dim MachNQDB As Database, MachNQSet As Recordset MAX_PERCENTAGE_OVER_LOWEST_RUNTIME = 1.2 Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set search criteria. Set MachQDB = DBEngine.Workspaces(0).Databases(0) Set MachQSet = MachQDB.OpenRecordset("MachinesQ1", DB_OPEN_DYNASET) ' Create dynaset. 'Set MachQDB = DBEngine.Workspaces(0).Databases(0) 'Set MachQSet = StMachQ2Set currform!txtCalcStat.Caption = "Determine cnc highest runtime" MachQSet.FindFirst Criteria$ ' Find first occurrence. Do Until MachQSet.NoMatch ' Loop until no matching records. If MachQSet!Prime = True Then PMachine$ = MachQSet!MachineName PWC1$ = MachQSet!Tool PCTime! = MachQSet!CycleTime End If MachQSet.FindNext Criteria$ ' Find next occurrence. DoEvents Loop LOWEST_RUNTIME = 100000 MachQSet.FindFirst Criteria$ ' Find first occurrence. Do Until MachQSet.NoMatch ' Loop until no matching records. MN$ = MachQSet!MachineName On Error GoTo toolset TL$ = MachQSet!Tool Cy! = Val(MachQSet!CycleTime) If PMachine$ = "C-1000" Or PMachine$ = "C-2000" Then If MN$ = "C-1000" Or MN$ = "C-2000" Then ck = 1 Else ck = 0 End If Else If MN$ = "C-1000" Or MN$ = "C-2000" Then ck = 0 Else ck = 1 End If End If If ck = 1 Then If (TL$ = "STD") Or (TL$ = "R/S") Then If (Cy! < LOWEST_RUNTIME) And (Cy! > 0) Then LOWEST_RUNTIME = Cy! REPOSITION_FLAG$ = TL$ End If End If End If MachQSet.FindNext Criteria$ Loop MAX_HIGHEST_RUNTIME = LOWEST_RUNTIME * MAX_PERCENTAGE_OVER_LOWEST_RUNTIME CNC_Highest_RunTime = LOWEST_RUNTIME MachQSet.FindFirst Criteria$ ' Find first occurrence. Do Until MachQSet.NoMatch ' Loop until no matching records. MN$ = MachQSet!MachineName On Error GoTo toolset TL$ = MachQSet!Tool Cy! = Val(MachQSet!CycleTime) If PMachine$ = "C-1000" Or PMachine$ = "C-2000" Then If MN$ = "C-1000" Or MN$ = "C-2000" Then ck = 1 Else ck = 0 End If Else If MN$ = "C-1000" Or MN$ = "C-2000" Then ck = 0 Else ck = 1 End If End If If ck = 1 Then If (TL$ = "STD") Or (TL$ = "R/S") Then If (Cy! <= MAX_HIGHEST_RUNTIME) And (Cy! > LOWEST_RUNTIME) And (Cy! > CNC_Highest_RunTime) And (Cy! > 0) Then CNC_Highest_RunTime = Cy! REPOSITION_FLAG$ = TL$ End If End If End If MachQSet.FindNext Criteria$ DoEvents Loop If CNC_Highest_RunTime! < PCTime! Then CNC_Highest_RunTime! = PCTime! End If If CNC_Highest_RunTime = 100000 Then currform![CalculationStatus] = 8 End If Exit Sub toolset: TL$ = "" On Error GoTo 0 Resume Next End Sub Sub Det_CNC_Standard(CNC_STD, CNC_Highest_RunTime, Repostition_Flag$) currform!txtCalcStat.Caption = "Determine cnc standard" Call Elem_ClearArray ACTIVATE_PRESS = 0.013 REPOSITION_TIME = 0.043 Paper_Work = 0.06 MAJOR_DIM = 40 Major_Dim_Time = 0.06 CNC_Pfd = 1.1 If (PMachine$ = "C-3000") Or (PMachine$ = "C-4000") Or (PMachine$ = "C-5000") Or (PMachine$ = "C-6000") Or (PMachine$ = "C-7000") Or (PMachine$ = "C-8000") Or (PMachine$ = "C-9000") Or (PMachine$ = "V-1000") Or (PMachine$ = "V-2000") Or (PMachine$ = "V-4000") Or (PMachine$ = "C10000") Then If Multi$ = "MULTIPLE" And (Not (SecondShear)) Then CNC_Pfd = 1.15 End If End If Elem!(33) = (CNC_Pfd - 1) * 100 Blank_wt = First_Dim! * Second_dim! / 144 * lb_per_sq_ft! If (First_Dim! > 36) Or (Second_dim! > 36) Then LOAD_TIME = 0.214 If Blank_wt <= 4 Then UNLOAD_TIME = 0.061 If (Blank_wt > 4) And (Blank_wt <= 8) Then UNLOAD_TIME = 0.062 If (Blank_wt > 8) And (Blank_wt <= 12) Then UNLOAD_TIME = 0.063 If (Blank_wt > 12) And (Blank_wt <= 20) Then UNLOAD_TIME = 0.064 If Blank_wt > 20 Then UNLOAD_TIME = 0.065 Else If (First_Dim! > 15) Or (Second_dim! > 15) Then LOAD_TIME = 0.171 If Blank_wt <= 4 Then UNLOAD_TIME = 0.05 If (Blank_wt > 4) And (Blank_wt <= 8) Then UNLOAD_TIME = 0.051 If (Blank_wt > 8) And (Blank_wt <= 12) Then UNLOAD_TIME = 0.052 If (Blank_wt > 12) And (Blank_wt <= 20) Then UNLOAD_TIME = 0.053 If Blank_wt > 20 Then UNLOAD_TIME = 0.054 Else LOAD_TIME = 0.107 If Blank_wt <= 4 Then UNLOAD_TIME = 0.039 If (Blank_wt > 4) And (Blank_wt <= 8) Then UNLOAD_TIME = 0.04 If (Blank_wt > 8) And (Blank_wt <= 12) Then UNLOAD_TIME = 0.041 If (Blank_wt > 12) And (Blank_wt <= 20) Then UNLOAD_TIME = 0.042 If Blank_wt > 20 Then UNLOAD_TIME = 0.043 End If End If CNC_STD = 0 Machine_Cycle = CNC_Highest_RunTime / 60 Elem!(23) = CNC_Highest_RunTime Elem!(24) = 60 Elem!(22) = Machine_Cycle If Repostition_Flag$ = "R/S" Then CNC_STD = REPOSITION_TIME Elem!(14) = CNC_STD End If If (First_Dim! > MAJOR_DIM) Or (Second_dim! > MAJOR_DIM) Then CNC_STD = CNC_STD + Major_Dim_Time Elem!(26) = Major_Dim_Time End If CNC_STD = CNC_STD + ACTIVATE_PRESS CNC_STD = CNC_STD + LOAD_TIME CNC_STD = CNC_STD + UNLOAD_TIME CNC_STD = CNC_STD + Machine_Cycle CNC_STD = CNC_STD + Paper_Work CNC = CNC_STD Elem!(6) = LOAD_TIME Elem!(10) = ACTIVATE_PRESS Elem!(18) = UNLOAD_TIME If (Multi$ = "MULTIPLE") Or (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "SLUG") Or (Multi$ = "LASER/SHEAR") Then CNC_STD = CNC_STD / Parts_Per_blank ppb = Parts_Per_blank Else ppb = 1 End If CNC_STD = CNC_STD * CNC_Pfd / 60 Elem!(31) = Internal_Labor! Elem!(32) = Internal_Walk! Elem!(30) = Internal_Labor! + Internal_Walk! Elem!(0) = Paper_Work ' Paperwork Elem!(1) = CNC ' total select time Elem!(2) = ppb ' # of parts Elem!(3) = Elem!(1) / Elem!(2) ' # of minutes Elem!(4) = Elem!(3) * CNC_Pfd ' over head Elem!(5) = Elem!(4) / 60 ' standard hours typ$ = " " PartN$ = currform!PartNumber Call Elem_Add(PartN$, typ$, "CNC") End Sub Sub Det_Deburr_Run_Times(CNCTime!, DbProcSel%, complete%) RU_PER_PACE = 0.01 paces_from_CNC_to_Shear = 4 paces_from_CNC_to_Timesaver = 3.2 paces_from_CNC_to_Pedestal = 3.78 paces_from_Shear_to_Pedestal = 2 paces_from_Shear_to_Timesaver = 1.6 paces_from_Shear_to_Line = 7.2 paces_from_Pedestal_to_Timesaver = 3 paces_from_Pedestal_to_Line = 8.2 paces_from_Line_to_CNC = 6 pfd = 1.15 If Multi$ = "MULTIPLE" Then MultiNoParts = Parts_Per_blank Else MultiNoParts = 1 End If currform!txtCalcStat.Caption = "Determine deburr run times" DoEvents Calc_Mult_Hnd_DB: Call Det_HandDeburr(mhdb!, rx!, 4) mhdb! = mhdb! * 60 Calc_Mult_TS_DB: Call Det_TimeSaver_Labor(mts!, rx!, False, BadTs%) mts! = mts! * 60 If BadTs% Then dbtype!(15, 0) = 0 dbtype!(16, 0) = 0 End If Calc_TimeSaver: Call Det_TimeSaver_Labor(ts!, rx!, True, BadTs%) ts! = ts! * 60 If BadTs% Then dbtype!(2, 0) = 0 dbtype!(7, 0) = 0 dbtype!(10, 0) = 0 End If Calc_Shear: Call Det_Mult_Shear(SHEAR!, TShear!) SHEAR! = SHEAR! * 60 TShear! = TShear! * 60 Calc_Hand_DB1: Call Det_HandDeburr(HDB1!, rx!, 1) HDB1! = HDB1! * 60 Calc_Hand_DB2: Call Det_HandDeburr(HDB2!, rx!, 2) HDB2! = HDB2! * 60 Calc_Hand_DB4: Call Det_HandDeburr(hdb4!, rx!, 3) hdb4! = hdb4! * 60 Calc_Hand_DBAddnl: Call Det_HandDeburr(ahdb!, rx!, 5) ahdb! = ahdb! * 60 Calc_Pdstl_DB1: PDB1! = 0 Call Det_Pedestal_Grinder_Standard(Actual_PartHeight!, Actual_PartWidth!, 2, 1!, PDB1!) PDB1! = PDB1! * 60 Calc_Pdstl_DB2: PDB2! = 0 Call Det_Pedestal_Grinder_Standard(Actual_PartHeight!, Actual_PartWidth!, 4, 1!, PDB2!) PDB2! = PDB2! * 60 Calc_Pdstl_DB4: PDB4! = 0 Call Det_Pedestal_Grinder_Standard(Actual_PartHeight!, Actual_PartWidth!, 8, 1!, PDB4!) PDB4! = PDB4! * 60 Quickest = 0 For dbproc = 1 To 16 If dbtype!(dbproc, 0) = 1 Then Paces! = 0 complete% = 0 On dbproc GoSub dbp1, dbp2, dbp3, dbp4, dbp5, dbp6, dbp7, dbp8, dbp9, dbp10, dbp11, dbp12, dbp13, dbp14, dbp15, dbp16 dbtype!(dbproc, 1) = dbt! + (Paces! * RU_PER_PACE * 60) If complete% = 0 And (dbtype!(dbproc, 1) <= CNCTime!) Then If Quickest = 0 Then Quickest = dbproc QComplete = complete% End If If (dbtype!(dbproc, 1) < dbtype!(Quickest, 1)) Then Quickest = dbproc QComplete = complete% End If End If Else dbtype!(dbproc, 1) = 0 End If DoEvents Next complete% = QComplete If Quickest = 0 Then For i = 1 To 5 Select Case i Case 1 dbproc = 16 complete% = 1 Case 2 dbproc = 13 complete% = 1 Case 3 dbproc = 14 complete% = 2 Case 4 dbproc = 15 complete% = 1 Case 5 dbproc = 1 complete% = 1 Case Else End Select If (dbtype!(dbproc, 1) <= CNCTime!) And (dbtype!(dbproc, 1) <> 0) Then Quickest = dbproc Exit For End If Next End If DbProcSel% = Quickest If DbProcSel% <> 0 Then On DbProcSel% GoSub dbp1, dbp2, dbp3, dbp4, dbp5, dbp6, dbp7, dbp8, dbp9, dbp10, dbp11, dbp12, dbp13, dbp14, dbp15, dbp16 Internal_Labor! = dbt! Internal_Walk! = (Paces! * RU_PER_PACE * 60) Else Internal_Labor! = 0 Internal_Walk! = 0 complete% = 2 End If Exit Sub dbp1: dbt! = mhdb! + ahdb! Paces! = 0 complete% = 1 Return dbp2: dbt! = ts! Paces! = paces_from_CNC_to_Timesaver + paces_from_Line_to_CNC Return dbp3: dbt! = mhdb! + SHEAR! + HDB1! * MultiNoParts + ahdb! Paces! = paces_from_CNC_to_Shear + paces_from_Shear_to_Line + paces_from_Line_to_CNC Return dbp4: dbt! = mhdb! + SHEAR! + HDB2! * MultiNoParts + ahdb! Paces! = paces_from_CNC_to_Shear + paces_from_Shear_to_Line + paces_from_Line_to_CNC Return dbp5: dbt! = mhdb! + SHEAR! + PDB1! * MultiNoParts + ahdb! Paces! = paces_from_CNC_to_Shear + paces_from_Shear_to_Pedestal + paces_from_Pedestal_to_Line + paces_from_Line_to_CNC Return dbp6: dbt! = mhdb! + SHEAR! + PDB2! * MultiNoParts + ahdb! Paces! = paces_from_CNC_to_Shear + paces_from_Shear_to_Pedestal + paces_from_Pedestal_to_Line + paces_from_Line_to_CNC Return dbp7: dbt! = mhdb! + TShear! + ts! * MultiNoParts '------not used Paces! = paces_from_CNC_to_Shear + paces_from_Shear_to_Timesaver + paces_from_Line_to_CNC Return dbp8: dbt! = SHEAR! + hdb4! * MultiNoParts + ahdb! Paces! = paces_from_CNC_to_Shear + paces_from_Shear_to_Line + paces_from_Line_to_CNC Return dbp9: dbt! = SHEAR! + PDB4! * MultiNoParts + ahdb! Paces! = paces_from_CNC_to_Shear + paces_from_Shear_to_Pedestal + paces_from_Pedestal_to_Line + paces_from_Line_to_CNC Return dbp10: dbt! = TShear! + ts! * MultiNoParts Paces! = paces_from_CNC_to_Shear + paces_from_Shear_to_Timesaver + paces_from_Line_to_CNC Return dbp11: dbt! = hdb4! + ahdb! Paces! = (paces_from_Line_to_CNC + paces_from_Line_to_CNC) / 4 Return dbp12: dbt! = PDB4! + ahdb! Paces! = (paces_from_CNC_to_Pedestal + paces_from_Pedestal_to_Line + paces_from_Line_to_CNC) / 4 Return dbp13: dbt! = mhdb! + SHEAR! + ahdb! Paces! = paces_from_CNC_to_Shear + paces_from_CNC_to_Shear complete% = 1 Return dbp14: dbt! = SHEAR! Paces! = paces_from_CNC_to_Shear + paces_from_CNC_to_Shear complete% = 2 Return dbp15: dbt! = mts! Paces! = paces_from_CNC_to_Timesaver + paces_from_Line_to_CNC complete% = 1 Return dbp16: dbt! = mts! + TShear! Paces! = paces_from_CNC_to_Timesaver + paces_from_Shear_to_Line + paces_from_CNC_to_Shear complete% = 1 Return End Sub Sub Det_HandDeburr(Labor!, Rstd!, HDB%) ' ' HDB = 1 Hand Deburr 1 ' 2 Hand Deburr 2 ' 3 Hand Deburr 4 ' 4 Multiple Hand Deburr ' 5 Additional Hand Deburr ' currform!txtCalcStat.Caption = "Determine hand deburr" DoEvents PartN$ = currform![PartNumber] Elem1! = 0.036 ppb = 1 Select Case HDB% Case 1 Inches = Actual_PartWidth! edg$ = "1Edg" Case 2 Inches = Actual_PartWidth! * 2 edg$ = "2Edg" Case 3 Inches = Actual_PartHeight! * 2 + Actual_PartWidth! * 2 edg$ = "4Edg" Case 4 ppb = Parts_Per_blank! If ppb = 0 Then ppb = 1 Inches = Actual_PartHeight! * (ppb + 1) If TopTrimCut <> 0 Then Inches = Inches + Actual_PartWidth! * ppb End If edg$ = "MEdg" Case 5 Inches = ItsAZero(currform!AddnlDeburrInches) If Inches = 0 Then Elem1! = 0 edg$ = "AEdg" Case Else Inches = 0 End Select Elem2! = Inches * 0.002 Labor! = Elem1! + Elem2! Elem!(6) = Elem1! 'Elem1A Elem!(10) = Elem2! 'Elem2A Elem!(11) = Inches 'Elem2V1 Elem!(14) = Labor! * 60 Elem!(0) = 0 ' Paperwork Elem!(1) = Labor! ' total select time Elem!(2) = 1 ' # of parts Elem!(3) = Elem!(1) / Elem!(2) ' # of minutes Elem!(4) = Elem!(3) * 1.15 ' over head Elem!(5) = Elem!(4) / 60 ' standard hours Rstd! = Elem!(5) Call Elem_Add(PartN$, edg$, "HANDDEBURR") End Sub Sub Det_Shake(ForP$, Rstd!) ' ' Shake and Break time ' currform!txtCalcStat.Caption = "Determine Shake and Break" DoEvents PartN$ = currform![PartNumber] Select Case ForP$ Case "F" 'is this a Fab Shake n break? Elem1! = 0.01 Elem2! = 0.17153915 ' was .1199 Case "FM" 'certian metals and difficulties in safety handling Elem1! = 0.01 Elem2! = 0.180095652 ' was .1199 from Kenny Law time study should now be .1803 (due to added Safety proceedures) Case Else 'no this is a pot Elem1 = 0 Elem2 = 0.2 End Select Labor! = Elem1! + Elem2! Elem!(6) = Elem1! 'Elem1A Elem!(10) = Elem2! 'Elem2A Elem!(14) = Labor! * 60 Elem!(0) = 0.033 ' Paperwork Elem!(1) = Labor! + 0.033 ' total select time Elem!(2) = 1 ' # of parts Elem!(3) = Elem!(1) / Elem!(2) ' # of minutes Elem!(4) = Elem!(3) * 1.15 ' over head Elem!(5) = Elem!(4) / 60 ' standard hours Rstd! = Elem!(5) Call Elem_Add(PartN$, " ", "SHAKEBREAK") End Sub Sub Det_LASER_Standard(PN$, Rstd!, ctime!) Dim MachQDB As Database, MachQSet As Recordset Dim MachNQDB As Database, MachNQSet As Recordset Criteria$ = "PartNumber = '" + PN$ + "'" ' Set search criteria. Set MachQDB = DBEngine.Workspaces(0).Databases(0) Set MachQSet = MachQDB.OpenRecordset("MachinesQ1", DB_OPEN_DYNASET) ' Create dynaset. currform!txtCalcStat.Caption = "Doing Laser Standard" MachQSet.FindFirst Criteria$ ' Find first occurrence. Do Until MachQSet.NoMatch ' Loop until no matching records. If MachQSet!Prime = True Then PMachine$ = MachQSet!MachineName PWC1$ = MachQSet!Tool PCTime! = MachQSet!CycleTime Exit Do End If MachQSet.FindNext Criteria$ ' Find next occurrence. DoEvents Loop Paperwork = 0.06 Activate = 0.013 pfd = 1.1 ctime! = PCTime! md = First_Dim! If md < Second_dim! Then md = Second_dim! End If Rus = 0 Select Case md Case Is <= 15 Rus = 0.107 Case Is <= 36 Rus = 0.171 Case Else Rus = 0.214 End Select ct = ctime! / 60 SelectTime = Rus + Activate + ct + Paperwork Mstd! = (SelectTime / Parts_Per_blank!) Rstd! = Mstd! * pfd / 60 Elem!(6) = Rus 'Elem1A Elem!(10) = Activate 'Elem2A Elem!(14) = ct 'Elem3A Elem!(15) = ctime! 'Elem3V1 Elem!(16) = 60 'Elem3V2 Elem!(0) = Paperwork 'PaperWork Elem!(1) = SelectTime 'TotalSelectTime Elem!(2) = Parts_Per_blank! 'StandardParts Elem!(3) = Mstd! 'StandardParts/Min Elem!(4) = pfd * Mstd! 'PFd Elem!(5) = Rstd! 'StandardParts/Hour Call Elem_Add(PN$, " ", "LASER") End Sub Sub Det_Salvagnini_Standard(PN$, Rstd!, ctime!) Dim MachQDB As Database, MachQSet As Recordset Dim MachNQDB As Database, MachNQSet As Recordset Criteria$ = "PartNumber = '" + PN$ + "'" ' Set search criteria. Set MachQDB = DBEngine.Workspaces(0).Databases(0) Set MachQSet = MachQDB.OpenRecordset("MachinesQ1", DB_OPEN_DYNASET) ' Create dynaset. currform!txtCalcStat.Caption = "Doing Salvagnini Standard" MachQSet.FindFirst Criteria$ ' Find first occurrence. Do Until MachQSet.NoMatch ' Loop until no matching records. If MachQSet!Prime = True Then PMachine$ = MachQSet!MachineName PWC1$ = MachQSet!Tool PCTime! = MachQSet!CycleTime Exit Do End If MachQSet.FindNext Criteria$ ' Find next occurrence. DoEvents Loop Paperwork = 0.06 pfd = 1.1 ctime! = PCTime! ct = ctime! / 60 SelectTime = ct + Paperwork Mstd! = (SelectTime) Rstd! = Mstd! * pfd / 60 Elem!(6) = ct 'Elem1A Elem!(0) = Paperwork 'PaperWork Elem!(1) = SelectTime 'TotalSelectTime Elem!(2) = 1! 'StandardParts Elem!(3) = Mstd! 'StandardParts/Min Elem!(4) = pfd * Mstd! 'PFd Elem!(5) = Rstd! 'StandardParts/Hour Call Elem_Add(PN$, "SALV", "SALVAGNINI") End Sub Sub Det_Mult_Shear(SHEAR!, TShear!) Paperwork = 0.06 currform!txtCalcStat.Caption = "Determine multiple shear runtime" pfd = 1.15 Call Elem_ClearArray Blank_wt = First_Dim! * Second_dim! / 144 * lb_per_sq_ft! If (Actual_PartHeight < 5.5) And (Actual_PartWidth < 5.5) Then ' 5.5 - the fixture is used when less than 5.5 Elem!(6) = 0.09 Elem!(7) = 1 Elem!(10) = 0.03 Elem!(11) = 1 Elem!(14) = 0.045 Elem!(15) = 1 End If Elem!(6) = Elem!(6) * Elem!(7) Elem!(10) = Elem!(10) * Elem!(11) Elem!(14) = Elem!(14) * Elem!(15) Elem1 = Elem!(6) + Elem!(10) + Elem!(14) Elem!(18) = 0.015 Elem!(19) = 1 Elem!(22) = 0.021 Elem!(23) = 1 Elem!(42) = 0.039 Elem!(43) = 1 If TOP_TRIM_CUT > 0 Then Elem!(19) = 2 Elem!(23) = 2 Elem3 = 0.014 Select Case Blank_wt Case Is < 4 Elem4 = 0.027 Case Is < 10 Elem4 = 0.029 Case Is < 20 Elem4 = 0.031 Case Is < 30 Elem4 = 0.033 Case Is < 40 Elem4 = 0.035 Case Else End Select Elem!(30) = Elem3 Elem!(31) = 1 Elem!(46) = Elem4 Elem!(47) = Elem4 * 1000 Elem!(48) = 1 Else Elem3 = 0 Elem4 = 0 End If Elem!(18) = Elem!(18) * Elem!(19) Elem!(22) = Elem!(22) * Elem!(23) Elem!(42) = Elem!(42) * Elem!(43) Elem2 = Elem!(18) + Elem!(22) + Elem!(42) If Bottom_Trim_Cut > 0 Then Elem3 = Elem3 + 0.014 Elem!(34) = 0.014 Elem!(35) = 1 End If Select Case Blank_wt Case Is < 4 Elem5 = 0.053 Elem6 = 0.067 Case Is < 10 Elem5 = 0.062 Elem6 = 0.079 Case Else Elem5 = 0.074 Elem6 = 0.095 End Select Elem!(38) = Elem5 Elem!(39) = Elem5 * 1000 Elem!(40) = 1 SHEAR! = Elem1 + Elem2 + Elem3 + Elem4 + Elem5 TShear! = Elem1 + Elem2 + Elem3 + Elem4 + Elem6 Elem!(50) = SHEAR * 60 Elem!(0) = Paperwork ' Paperwork Elem!(1) = SHEAR + Paperwork ' total select time Elem!(2) = 1 ' # of parts Elem!(3) = Elem!(1) / Elem!(2) ' # of minutes Elem!(4) = Elem!(3) * pfd ' over head Elem!(5) = Elem!(4) / 60 ' standard hours PartN$ = currform!PartNumber Call Elem_Add(PartN$, "CONT", "MULTSHEAR") Elem!(38) = Elem6 Elem!(39) = Elem6 * 1000 Elem!(40) = 1 Elem!(50) = TShear * 60 Elem!(0) = Paperwork ' Paperwork Elem!(1) = TShear + Paperwork ' total select time Elem!(2) = 1 ' # of parts Elem!(3) = Elem!(1) / Elem!(2) ' # of minutes Elem!(4) = Elem!(3) * pfd ' over head Elem!(5) = Elem!(4) / 60 ' standard hours Call Elem_Add(PartN$, "T/S ", "MULTSHEAR") End Sub Sub Det_Pedestal_Grinder_Standard(DIMENSION_1, DIMENSION_2, Side%, RunStd!, Labor!) ' ' Side ' 1 PEDESTAL_GRINDER_STD_1, ' 2 PEDESTAL_GRINDER_STD_2, ' 3 PEDESTAL_GRINDER_STD_11, ' 4 PEDESTAL_GRINDER_STD_22, ' 5 PEDESTAL_GRINDER_STD_12, ' 6 PEDESTAL_GRINDER_STD_112, ' 7 PEDESTAL_GRINDER_STD_122, ' 8 PEDESTAL_GRINDER_STD_1122, ' ' 1 PEDESTAL_GRINDER_LABOR_1, ' 2 PEDESTAL_GRINDER_LABOR_2, ' 3 PEDESTAL_GRINDER_LABOR_11, ' 4 PEDESTAL_GRINDER_LABOR_22, ' 5 PEDESTAL_GRINDER_LABOR_12, ' 6 PEDESTAL_GRINDER_LABOR_112, ' 7 PEDESTAL_GRINDER_LABOR_122, ' 8 PEDESTAL_GRINDER_LABOR_1122 ' Call Elem_ClearArray PartN$ = currform![PartNumber] currform!txtCalcStat.Caption = "Determine Pedestal grinder Standard" Paperwork = 0.01 PEDESTAL_GRINDER_MACHINE_TIME_PER_INCH = 0.005 Pedestal_Grinder_Pfd = 1.15 If Labor! = 1 Then noelem = 1 Else noelem = 0 Blank_wt = DIMENSION_1 * DIMENSION_2 / 144 * lb_per_sq_ft! Body_Movements = 2 * 0.01 '(* TURN OR WALK/PACE *) If (DIMENSION_1 > 30) Or (DIMENSION_2 > 30) Then SINGLE_EDGE_HANDLING = 0.066 MULTIPLE_EDGE_HANDLING = 0.036 Else If (DIMENSION_1 > 20) Or (DIMENSION_2 > 20) Then SINGLE_EDGE_HANDLING = 0.058 MULTIPLE_EDGE_HANDLING = 0.032 Else If (DIMENSION_1 > 10) Or (DIMENSION_2 > 10) Then SINGLE_EDGE_HANDLING = 0.05 MULTIPLE_EDGE_HANDLING = 0.028 Else If (DIMENSION_1 > 4) Or (DIMENSION_2 > 4) Then SINGLE_EDGE_HANDLING = 0.041 MULTIPLE_EDGE_HANDLING = 0.024 Else SINGLE_EDGE_HANDLING = 0.033 MULTIPLE_EDGE_HANDLING = 0.02 End If End If End If End If Select Case Side% Case 1 TOTAL_INCHES_DEBURRED = DIMENSION_1 Number_Of_Edges_Deburred = 1 typ$ = "1Edg" Case 2 TOTAL_INCHES_DEBURRED = DIMENSION_2 Number_Of_Edges_Deburred = 1 typ$ = "1Edg" Case 3 TOTAL_INCHES_DEBURRED = DIMENSION_1 * 2 Number_Of_Edges_Deburred = 2 typ$ = "2Edg" Case 4 TOTAL_INCHES_DEBURRED = DIMENSION_2 * 2 Number_Of_Edges_Deburred = 2 typ$ = "2Edg" Case 5 TOTAL_INCHES_DEBURRED = DIMENSION_1 + DIMENSION_2 Number_Of_Edges_Deburred = 2 typ$ = "2Edg" Case 6 TOTAL_INCHES_DEBURRED = DIMENSION_1 * 2 + DIMENSION_2 Number_Of_Edges_Deburred = 3 typ$ = "3Edg" Case 7 TOTAL_INCHES_DEBURRED = DIMENSION_1 + DIMENSION_2 * 2 Number_Of_Edges_Deburred = 3 typ$ = "3Edg" Case 8 TOTAL_INCHES_DEBURRED = DIMENSION_1 * 2 + DIMENSION_2 * 2 Number_Of_Edges_Deburred = 4 typ$ = "4Edg" Case Else End Select Pedestal_Grinder_Handling_Time = (Number_Of_Edges_Deburred - 1) * MULTIPLE_EDGE_HANDLING + SINGLE_EDGE_HANDLING PEDESTAL_GRINDER_MACHINE_TIME = TOTAL_INCHES_DEBURRED * PEDESTAL_GRINDER_MACHINE_TIME_PER_INCH Pedestal_Grinder_Labor = 0 Pedestal_Grinder_Labor = Pedestal_Grinder_Handling_Time + PEDESTAL_GRINDER_MACHINE_TIME + Body_Movements PEDESTAL_GRINDER_STD = (Pedestal_Grinder_Labor + Paperwork) * Pedestal_Grinder_Pfd / 60 Labor! = Pedestal_Grinder_Labor RunStd! = PEDESTAL_GRINDER_STD Elem!(6) = SINGLE_EDGE_HANDLING Elem!(7) = SINGLE_EDGE_HANDLING * 1000 Elem!(10) = (Number_Of_Edges_Deburred - 1) * MULTIPLE_EDGE_HANDLING Elem!(12) = (Number_Of_Edges_Deburred - 1) Elem!(11) = MULTIPLE_EDGE_HANDLING * 1000 Elem!(14) = TOTAL_INCHES_DEBURRED * PEDESTAL_GRINDER_MACHINE_TIME_PER_INCH Elem!(15) = TOTAL_INCHES_DEBURRED Elem!(18) = Body_Movements Elem!(22) = Pedestal_Grinder_Labor * 60 Elem!(0) = Paperwork ' Paperwork Elem!(1) = Pedestal_Grinder_Labor + Paperwork ' total select time Elem!(2) = 1 ' # of parts Elem!(3) = Elem!(1) / Elem!(2) ' # of minutes Elem!(4) = Elem!(3) * Pedestal_Grinder_Pfd ' over head Elem!(5) = Elem!(4) / 60 ' standard hours If noelem = 0 Then Call Elem_Add(PartN$, typ$, "PEDESTAL") End If End Sub Sub DET_PressBrake_Standard(r!, hits, w2$, W3$, W4$, M$) Dim PressTab As Database, PressTabSet As Recordset Set PressTab = DBEngine.Workspaces(0).Databases(0) Set PressTabSet = PressTab.OpenRecordset("PressBrakes", DB_OPEN_TABLE) currform!txtCalcStat.Caption = "Determine pressbrake runtime" Call Elem_ClearArray PressTabSet.Index = "ByType" PressTabSet.MoveFirst PressTabSet.Seek ">=", currform!PressBrake If Not (NoMatch) Then w2$ = PressTabSet!wc2 If w2$ = "302" Then w2$ = warehousewc$ W3$ = PressTabSet!wc3 W4$ = PressTabSet!wc4 M$ = PressTabSet!PressBrake End If pfd = 1.15 Paperwork = 0.033 ' If Multi$ = "LASER" Then Blank_wt = Actual_PartHeight! * Actual_PartWidth! / 144 * lb_per_sq_ft! ' Else ' Blank_Wt = Part_Height! * Part_Width! / 144 * lb_per_sq_ft! ' End If Select Case Blank_wt Case Is <= 4 elm5 = 0.048 elm7 = 0.032 frq = 0 Case Is <= 8 elm5 = 0.071 elm7 = 0.036 frq = 4 Case Is <= 12 elm5 = 0.085 elm7 = 0.041 frq = 8 Case Is <= 20 elm5 = 0.095 elm7 = 0.045 frq = 12 Case Else elm5 = 0.102 elm7 = 0.05 frq = 16 End Select Elem!(6) = elm5 Elem!(11 + frq) = hits - 1 elm7 = (hits - 1) * elm7 Elem!(10 + frq) = elm7 elm9 = hits * 0.069 ' 0.069 Elem!(30) = elm9 Elem!(31) = hits elm11 = hits * 0.083 Elem!(34) = elm11 Elem!(35) = hits Totaltime = elm5 + elm7 + elm9 + elm11 + Paperwork r! = Totaltime * pfd / 60 Elem!(0) = Paperwork ' Paperwork Elem!(1) = Totaltime ' total select time Elem!(2) = 1 ' # of parts Elem!(3) = Elem!(1) / Elem!(2) ' # of minutes Elem!(4) = Elem!(3) * pfd ' over head Elem!(5) = Elem!(4) / 60 ' standard hours typ$ = " " PartN$ = currform!PartNumber Call Elem_Add(PartN$, typ$, "PRESSBRAKE") Call ds_add("PRESSBRAKE", typ$) End Sub Sub DET_PEM_Standard(r!, hits, w2$, W3$, W4$, AM$) ' ' r! = runstd ' hits = number of presses ' W2-W4 = Work centers ' am$ = Auto or Manual ' Dim PemTab As Database, PemTabSet As Recordset ' Set PemTab = DBEngine.Workspaces(0).Databases(0) ' Set PemTabSet = PemTab.OpenRecordset("PEM", DB_OPEN_TABLE) currform!txtCalcStat.Caption = "Determine PEM runtime" Call Elem_ClearArray ' PressTabSet.Index = "ByType" ' PressTabSet.MoveFirst ' PressTabSet.Seek ">=", currform!PressBrake ' If Not (NoMatch) Then ' w2$ = PressTabSet.wc2 ' If w2$ = "302" Then w2$ = warehousewc$ ' W3$ = PressTabSet.wc3 ' W4$ = PressTabSet.wc4 ' M$ = PressTabSet.PressBrake ' End If pfd = 1.15 Paperwork = 0.01 ' If Multi$ = "LASER" Then ' Blank_Wt = Actual_PartHeight! * Actual_PartWidth! / 144 * lb_per_sq_ft! ' Else Blank_wt = CalculatedGrossWeight! ' End If ' Call CalcGrossWeight(110, 48, Gw!, Aw!, RC%) Select Case Blank_wt Case Is <= 4 elm5 = 0.048 elm6 = 0.032 frq = 10 Case Is <= 8 elm5 = 0.056 elm6 = 0.036 frq = 14 Case Is <= 12 elm5 = 0.063 elm6 = 0.041 frq = 18 Case Is <= 20 elm5 = 0.069 elm6 = 0.045 frq = 22 Case Else elm5 = 0.073 elm6 = 0.05 frq = 26 End Select Elem!(6) = elm5 If Left$(AM$, 1) = "A" Then amx = 0 em7a = 0.042 em7b = 0.047 Else amx = hits em7a = 0.058 em7b = 0.063 End If elm6 = (hits - 1) * elm6 Elem!(frq) = elm6 Elem!(frq + 1) = hits - 1 Elem!(32) = em7a Elem!(33) = em7b elm7 = hits * em7b Elem!(30) = elm7 Elem!(31) = hits elm9 = amx * 0.037 Elem!(38) = elm9 Elem!(39) = amx elm8 = 1 * 0.015 Elem!(34) = elm8 Elem!(35) = 1 Totaltime = elm5 + elm6 + elm7 + elm8 + elm9 + Paperwork r! = Totaltime * pfd / 60 Elem!(0) = Paperwork ' Paperwork Elem!(1) = Totaltime ' total select time Elem!(2) = 1 ' # of parts Elem!(3) = Elem!(1) / Elem!(2) ' # of minutes Elem!(4) = Elem!(3) * pfd ' over head Elem!(5) = Elem!(4) / 60 ' standard hours typ$ = AM$ PartN$ = currform!PartNumber Call Elem_Add(PartN$, typ$, "PEM") Call ds_add("PEM", typ$) End Sub Sub Det_Shear_Standard(QUADRANT, First_Cut_Std, Second_Cut_Std, Multiple_Cut_Std, Multiple_Cut_Labor) currform!txtCalcStat.Caption = "Determine shear runtimes" DoEvents PROGRAM_SETUP_TIME = 0.166 OBTAIN_AND_STARTUP_VACCULIFT = 0.099 WALK_TO_AND_FROM_MATERIAL_Q1 = 0.167 WALK_TO_AND_FROM_MATERIAL_Q2 = 0.32 WALK_TO_AND_FROM_MATERIAL_Q3 = 0.5 WALK_TO_AND_FROM_MATERIAL_Q4 = 0.667 OBTAIN_SHEET = 0.18 INSERT_TO_WRKHLDR_AND_STOP = 0.083 ACTIVATE_FOOT_PEDAL = 0.015 ACTIVATE_START_BUTTON = 0.015 RateR = 0.0024 PULLMAX_FIXED_FEEDRATE = 0.045 NIAGRA_FIXED_FEEDRATE = 0.028 PULLMAX_LAST_PART_EJECT = 0.05 NIAGRA_LAST_PART_EJECT = 0.024 PULLMAX_SQUARE_CUT = 0.045 NIAGRA_SQUARE_CUT = 0.028 REMOVE_SCRAP_AND_ASIDE = 0.039 PICK_UP_AND_MOVE_TO_SHEAR = 0.028 MOVE_AND_POSITION_PEICE = 0.024 REMOVE_REPOSITION_AND_REASSEMBLE = 0.029 Paperwork = 0.4 Shear_Pfd = 1.15 LOT_SIZE_RED_OFFALL = 0.8 + 0.05 '80% Lot size reduction and 5% offall (to be added to first cut pf&d) PartN$ = currform![PartNumber] Blank_wt = FirstCut * Sheet_Width / 144 * lb_per_sq_ft! If FirstCut >= Sheet_Width Then MAJOR_DIMENSION = FirstCut If FirstCut < Sheet_Width Then MAJOR_DIMENSION = Sheet_Width SPIN_BLANK_ON_FIRSTCUT = 0 SPIN_BLANK_ON_SECCUT = 0 SHEAR_1_OFFALL = Sheet_Length - TRIM_CUT_LENGTH - FirstCut * Blocks_Per_Sheet SHEAR_2_OFFALL = Sheet_Width - TRIM_CUT_LENGTH - SecondCut! * Blanks_Per_Block If (SHEAR_1_OFFALL < 2) And (Blocks_Per_Sheet > 1) Then SPIN_BLANK_ON_FIRSTCUT = REMOVE_REPOSITION_AND_REASSEMBLE If (SHEAR_2_OFFALL < 2) And (Blanks_Per_Block > 1) Then SPIN_BLANK_ON_SECCUT = REMOVE_REPOSITION_AND_REASSEMBLE WALK_TO_AND_FROM_MATERIAL = WALK_TO_AND_FROM_MATERIAL_Q1 If ExtraShear% Then First_Cut_Std = (RateR * SecondCut + PULLMAX_FIXED_FEEDRATE) * Blocks_Per_Sheet Else First_Cut_Std = (RateR * FirstCut + PULLMAX_FIXED_FEEDRATE) * Blocks_Per_Sheet End If First_Cut_Std = First_Cut_Std + PROGRAM_SETUP_TIME + OBTAIN_AND_STARTUP_VACCULIFT + WALK_TO_AND_FROM_MATERIAL First_Cut_Std = First_Cut_Std + OBTAIN_SHEET + INSERT_TO_WRKHLDR_AND_STOP First_Cut_Std = First_Cut_Std + ACTIVATE_FOOT_PEDAL + ACTIVATE_START_BUTTON + PULLMAX_LAST_PART_EJECT First_Cut_Std = First_Cut_Std + PULLMAX_SQUARE_CUT + REMOVE_SCRAP_AND_ASIDE + SPIN_BLANK_ON_FIRSTCUT + Paperwork GoSub CalcFirstCutStuff First_Cut_Std = First_Cut_Std / parts_per_sheet * (Shear_Pfd + LOT_SIZE_RED_OFFALL) / 60 Select Case Multi$ Case "SINGLE", "NO CNC", "LASER/SHEAR" SPIN_BLANK_ON_SECCUT = 0 If (SHEAR_2_OFFALL < 2) And (Blanks_Per_Block > 1) Then SPIN_BLANK_ON_SECCUT = REMOVE_REPOSITION_AND_REASSEMBLE Second_Cut_Std = (RateR * SecondCut! + NIAGRA_FIXED_FEEDRATE) * Blanks_Per_Block Second_Cut_Std = Second_Cut_Std + PROGRAM_SETUP_TIME Second_Cut_Std = Second_Cut_Std + ACTIVATE_FOOT_PEDAL Second_Cut_Std = Second_Cut_Std + ACTIVATE_START_BUTTON Second_Cut_Std = Second_Cut_Std + NIAGRA_LAST_PART_EJECT Second_Cut_Std = Second_Cut_Std + NIAGRA_SQUARE_CUT Second_Cut_Std = Second_Cut_Std + REMOVE_SCRAP_AND_ASIDE Second_Cut_Std = Second_Cut_Std + PICK_UP_AND_MOVE_TO_SHEAR Second_Cut_Std = Second_Cut_Std + MOVE_AND_POSITION_PEICE Second_Cut_Std = Second_Cut_Std + SPIN_BLANK_ON_SECCUT Second_Cut_Std = Second_Cut_Std + Paperwork GoSub CalcSecondCutStuff Second_Cut_Std = Second_Cut_Std / Blanks_Per_Block Second_Cut_Std = Second_Cut_Std * Shear_Pfd Second_Cut_Std = Second_Cut_Std / 60 Case "MULTIPLE" If ExtraShear% Then SPIN_BLANK_ON_SECCUT = 0 If (SHEAR_2_OFFALL < 2) And (Blanks_Per_Block > 1) Then SPIN_BLANK_ON_SECCUT = REMOVE_REPOSITION_AND_REASSEMBLE Second_Cut_Std = (RateR * FirstCut + NIAGRA_FIXED_FEEDRATE) * Blanks_Per_Block Second_Cut_Std = Second_Cut_Std + PROGRAM_SETUP_TIME Second_Cut_Std = Second_Cut_Std + ACTIVATE_FOOT_PEDAL Second_Cut_Std = Second_Cut_Std + ACTIVATE_START_BUTTON Second_Cut_Std = Second_Cut_Std + NIAGRA_LAST_PART_EJECT Second_Cut_Std = Second_Cut_Std + NIAGRA_SQUARE_CUT Second_Cut_Std = Second_Cut_Std + REMOVE_SCRAP_AND_ASIDE Second_Cut_Std = Second_Cut_Std + PICK_UP_AND_MOVE_TO_SHEAR Second_Cut_Std = Second_Cut_Std + MOVE_AND_POSITION_PEICE Second_Cut_Std = Second_Cut_Std + SPIN_BLANK_ON_SECCUT Second_Cut_Std = Second_Cut_Std + Paperwork GoSub CalcSecondCutStuff Second_Cut_Std = Second_Cut_Std / (Blanks_Per_Block * Parts_Per_blank!) Second_Cut_Std = Second_Cut_Std * Shear_Pfd Second_Cut_Std = Second_Cut_Std / 60 End If Number_Of_Top_Cuts = 0 If TOP_TRIM_CUT > 0 Then Number_Of_Top_Cuts = 1 Multiple_Cut_Labor = RateR * Bottom_Trim_Cut + NIAGRA_FIXED_FEEDRATE Multiple_Cut_Labor = ((RateR * TOP_TRIM_CUT + NIAGRA_FIXED_FEEDRATE) * Number_Of_Top_Cuts) + Multiple_Cut_Labor Multiple_Cut_Labor = Multiple_Cut_Labor + ACTIVATE_FOOT_PEDAL Multiple_Cut_Labor = Multiple_Cut_Labor + REMOVE_SCRAP_AND_ASIDE Multiple_Cut_Labor = Multiple_Cut_Labor + PICK_UP_AND_MOVE_TO_SHEAR Multiple_Cut_Labor = Multiple_Cut_Labor + MOVE_AND_POSITION_PEICE Multiple_Cut_Std = Multiple_Cut_Labor Multiple_Cut_Std = Multiple_Cut_Std + PROGRAM_SETUP_TIME Multiple_Cut_Std = Multiple_Cut_Std + NIAGRA_LAST_PART_EJECT Multiple_Cut_Std = Multiple_Cut_Std + ACTIVATE_START_BUTTON Multiple_Cut_Std = Multiple_Cut_Std + Paperwork GoSub CalcMultipleCutStuff Multiple_Cut_Std = Multiple_Cut_Std / Parts_Per_blank Multiple_Cut_Std = Multiple_Cut_Std * Shear_Pfd Multiple_Cut_Std = Multiple_Cut_Std / 60 Case Else End Select Exit Sub CalcFirstCutStuff: Call Elem_ClearArray Elem!(6) = 1 Elem!(7) = PROGRAM_SETUP_TIME Elem!(8) = 1 Elem!(9) = OBTAIN_AND_STARTUP_VACCULIFT Elem!(10) = 1 Elem!(11) = WALK_TO_AND_FROM_MATERIAL Elem!(12) = 1 Elem!(13) = OBTAIN_SHEET Elem!(14) = 1 Elem!(15) = INSERT_TO_WRKHLDR_AND_STOP Elem!(16) = 1 Elem!(17) = ACTIVATE_FOOT_PEDAL Elem!(18) = 1 Elem!(19) = ACTIVATE_START_BUTTON If ExtraShear% Then Elem!(20) = SecondCut Elem!(22) = (RateR * SecondCut + PULLMAX_FIXED_FEEDRATE) * Blocks_Per_Sheet Else Elem!(20) = FirstCut Elem!(22) = (RateR * FirstCut + PULLMAX_FIXED_FEEDRATE) * Blocks_Per_Sheet End If Elem!(21) = Blocks_Per_Sheet Elem!(29) = 1 Elem!(30) = PULLMAX_LAST_PART_EJECT Elem!(33) = 1 Elem!(34) = PULLMAX_SQUARE_CUT Elem!(37) = 1 Elem!(38) = REMOVE_SCRAP_AND_ASIDE If SPIN_BLANK_ON_FIRSTCUT <> 0 Then Elem!(43) = 1 Elem!(44) = SPIN_BLANK_ON_FIRSTCUT End If Elem!(0) = Paperwork ' Paperwork Elem!(1) = First_Cut_Std ' total select time Elem!(2) = parts_per_sheet ' # of parts Elem!(3) = Elem!(1) / Elem!(2) ' # of minutes Elem!(4) = Elem!(3) * (Shear_Pfd + LOT_SIZE_RED_OFFALL) ' over head Elem!(5) = Elem!(4) / 60 ' standard hours Elem!(46) = 85 ' Lot size reduction and offall Call Elem_Add(PartN$, "FRST", "SHEAR") Return CalcSecondCutStuff: Call Elem_ClearArray Elem!(6) = 1 Elem!(7) = PROGRAM_SETUP_TIME Elem!(16) = 1 Elem!(17) = ACTIVATE_FOOT_PEDAL Elem!(18) = 1 Elem!(19) = ACTIVATE_START_BUTTON If ExtraShear% Then Elem!(23) = FirstCut Elem!(25) = (RateR * FirstCut + NIAGRA_FIXED_FEEDRATE) * Blanks_Per_Block Else Elem!(23) = SecondCut! Elem!(25) = (RateR * SecondCut! + NIAGRA_FIXED_FEEDRATE) * Blanks_Per_Block End If Elem!(24) = Blanks_Per_Block Elem!(31) = 1 Elem!(32) = NIAGRA_LAST_PART_EJECT Elem!(35) = 1 Elem!(36) = NIAGRA_SQUARE_CUT Elem!(37) = 1 Elem!(38) = REMOVE_SCRAP_AND_ASIDE Elem!(39) = 1 Elem!(40) = PICK_UP_AND_MOVE_TO_SHEAR Elem!(41) = 1 Elem!(42) = MOVE_AND_POSITION_PEICE If SPIN_BLANK_ON_SECCUT <> 0 Then Elem!(43) = 1 Elem!(44) = SPIN_BLANK_ON_SECCUT End If Elem!(0) = Paperwork ' Paperwork Elem!(1) = Second_Cut_Std ' total select time If ExtraShear% Then Elem!(2) = Blanks_Per_Block * Parts_Per_blank! ' # of parts Else Elem!(2) = Blanks_Per_Block ' # of parts End If Elem!(3) = Elem!(1) / Elem!(2) ' # of minutes Elem!(4) = Elem!(3) * Shear_Pfd ' over head Elem!(5) = Elem!(4) / 60 ' standard hours Elem!(46) = 0 ' Lot size reduction and offall Call Elem_Add(PartN$, "SCND", "SHEAR") Return CalcMultipleCutStuff: Call Elem_ClearArray Elem!(6) = 1 Elem!(7) = PROGRAM_SETUP_TIME Elem!(16) = 1 Elem!(17) = ACTIVATE_FOOT_PEDAL Elem!(18) = 1 Elem!(19) = ACTIVATE_START_BUTTON Elem!(23) = Bottom_Trim_Cut Elem!(24) = 1 Elem!(25) = (RateR * Bottom_Trim_Cut + NIAGRA_FIXED_FEEDRATE) Elem!(26) = TOP_TRIM_CUT * Number_Of_Top_Cuts Elem!(27) = Number_Of_Top_Cuts Elem!(28) = (RateR * TOP_TRIM_CUT + NIAGRA_FIXED_FEEDRATE) * Number_Of_Top_Cuts Elem!(31) = 1 Elem!(32) = NIAGRA_LAST_PART_EJECT Elem!(35) = 1 Elem!(36) = NIAGRA_SQUARE_CUT Elem!(37) = 1 Elem!(38) = REMOVE_SCRAP_AND_ASIDE Elem!(39) = 1 Elem!(40) = PICK_UP_AND_MOVE_TO_SHEAR Elem!(41) = 1 Elem!(42) = MOVE_AND_POSITION_PEICE Elem!(0) = Paperwork ' Paperwork Elem!(1) = Multiple_Cut_Std ' total select time Elem!(2) = Parts_Per_blank ' # of parts Elem!(3) = Elem!(1) / Elem!(2) ' # of minutes Elem!(4) = Elem!(3) * Shear_Pfd ' over head Elem!(5) = Elem!(4) / 60 ' standard hours Elem!(46) = 0 ' Lot size reduction and offall Call Elem_Add(PartN$, "MULT", "SHEAR") Return End Sub Sub Det_TimeSaver_Labor(Labor!, Rstd!, shrd%, Bad%) ' ' labor is in minutes ' Standard is in hours ' currform!txtCalcStat.Caption = "Determine timesaver runtime" DoEvents PartN$ = currform![PartNumber] Call Elem_ClearArray pfd = 1.15 Paperwork = 0.01 If shrd% Then typ$ = "SHRD" If (Multi$ = "MULTIPLE") Or (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then Elem1 = 0.15 / Parts_Per_blank! Elem!(7) = Parts_Per_blank! ' Elem1V1 Else Elem1 = 0.15 Elem!(7) = 1 ' Elem1V1 End If If Actual_PartHeight > Actual_PartWidth Then MajorDim = Actual_PartHeight MinorDim = Actual_PartWidth Else MajorDim = Actual_PartWidth MinorDim = Actual_PartHeight End If Else typ$ = "MULT" Elem1 = 0.15 Elem!(7) = 1 ' Elem1V1 If First_Dim! > Second_dim! Then MajorDim = First_Dim! MinorDim = Second_dim! Else MajorDim = Second_dim! MinorDim = First_Dim! End If End If Elem!(6) = Elem1 ' Elem1A Elem!(8) = 1 ' Elem1V2 Elem2 = MajorDim * 0.002 Elem!(10) = Elem2 ' Elem2A Elem!(11) = MajorDim ' Elem2v1 Elem3 = 0.047 Elem!(14) = Elem3 ' Elem3A Labor! = Elem1 + Elem2 + Elem3 Elem!(18) = Labor! * 60 If (MinorDim > 36) Then Bad% = True Else Bad% = False End If Elem!(0) = Paperwork ' Paperwork Elem!(1) = Labor! + Paperwork ' total select time Elem!(2) = 1 ' # of parts Elem!(3) = Elem!(1) ' # of minutes Elem!(4) = Elem!(3) * pfd ' over head Elem!(5) = Elem!(4) / 60 ' standard hours Rstd! = Elem!(5) Call Elem_Add(PartN$, typ$, "TIMESAVER") End Sub Sub diskout() Dim MainDB As Database, MainSet As Recordset Dim Main2DB As Database, Main2Set As Recordset Dim MainTableDef As TableDef Dim DocName As String Dim LinkCriteria As String Dim MyForm As Form Set MainDB = DBEngine.Workspaces(0).Databases(0) Set Main2DB = DBEngine.Workspaces(0).Databases(0) ' currform.Refresh PN$ = currform!PartNumber Set MainSet = MainDB.OpenRecordset("Process", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("RMSFILES#_MSWKP811", DB_OPEN_DYNASET) ' Create dynaset. MainSet.Index = "PrimaryKey" ' Main2Set.Index = "PrimaryKey" Close #2 On Error Resume Next MkDir "C:\Files\Process\" On Error GoTo 0 Open "C:\Files\Process\junk.dat" For Output As #2 Print #2, "********** Beginning of Uploaded Text **********" MainSet.Seek ">=", PN$ If Not (MainSet.NoMatch) Then ' MainSet.MovePrevious If Not (MainSet.BOF) Then px$ = MainSet!PartNumber pps = MainSet!PartsPerSheet ' Print #2, rpad$("(" + Trim$(Str$(pps)) + "/SHEET)", 30) + lpad$("GR. WT.- " + Format$(MainSet!GrossWt, "0.000"), 30) ' Print #2, Center$("MATERIAL " + MainSet!MetalType, 60) hist$ = itsaNull$(MainSet!History) Call PARSE(hist$, eco$, ")", RCx%) If eco$ <> "" Then eco$ = eco$ + ")" prt$ = Trim$(MainSet!PartNumber) prt$ = "B" + Left$(prt$, 3) + "-" + Mid$(prt$, 4) ' Print #2, Center$(prt$ + " " + Trim$(MainSet!PartName), 60) ' Print #2, Center$(eco$, 60) ' Print #2, GoSub Getlines End If End If Print #2, "********** End of Uploaded Text **********" Close #2 Set Main2Set = Main2DB.OpenRecordset("RMSFILES#_MSWKP811", DB_OPEN_DYNASET) ' Create dynaset. On Error Resume Next Main2Set.MoveFirst On Error GoTo 0 Users$ = myNTUserName$ Do If Not (Main2Set.EOF) Then If Trim$(Main2Set![USERID]) = Users$ Then Main2Set.Delete End If DoEvents Else DoEvents Exit Do End If Main2Set.MoveNext Loop On Error Resume Next MkDir "C:\Files\Process\" On Error GoTo 0 Open "c:\Files\Process\junk.dat" For Input As #2 ' Main2Set.MoveFirst rec = 0 ptn$ = currform!PartNumber 'ptn$ = Left$(ptn$, 7) ptn$ = Mid(PN$, 1, Len(PN$) - 1) Set Main2Set = Main2DB.OpenRecordset("RMSFILES#_MSWKP811", DB_OPEN_DYNASET) ' Create dynaset. While Not (EOF(2)) Line Input #2, axc$ Main2Set.AddNew rec = rec + 10 Main2Set![USERID] = Users$ Main2Set![RECNO] = lpad$(Trim$(Str$(rec)), 5) Main2Set![UPLTXT] = axc$ Main2Set![PRD#] = rpad(ptn$, 15) Main2Set.Update Wend Close #2 Exit Sub Getlines: Set MainSet = MainDB.OpenRecordset("AP by PN and OPCode", DB_OPEN_DYNASET) ' MainSet.Index = "PartNumber" MainSet.FindFirst ("PartNumber = '" + PN$ + "'") If Not (MainSet.NoMatch) Then Do While Trim$(MainSet!PartNumber) = PN$ opcd$ = Left(Trim(itsaNull$(MainSet!OpCode)) + " ", 1) If InStr("!@#$%^&*", opcd$) = 0 Then A$ = "OP. " + Trim$(MainSet!OpCode) + " " A$ = A$ + Trim$(itsaNull$(MainSet!Machine)) + " - " A$ = A$ + MainSet!Description While InStr(A$, " ") <> 0 ix = InStr(A$, " ") A$ = Left$(A$, ix) + Mid$(A$, ix + 2) Wend Do While Len(A$) > 0 If Len(A$) <= 60 Then Print #2, A$ Exit Do End If bx$ = Left$(A$, 61) ix = LastInStr(bx$, " ") If ix = 0 Then ix = 60 If ix = 61 Then ix = 60 bx$ = Left$(A$, ix) A$ = Trim$(Mid$(A$, ix + 1)) Print #2, bx$ Loop Print #2, End If MainSet.MoveNext If (MainSet.EOF) Then Exit Do Loop End If Return End Sub Sub UpdateAS400() Dim MainDB As Database, MainSet As Recordset Dim Main2DB As Database, Main2Set As Recordset Set MainDB = DBEngine.Workspaces(0).Databases(0) ' currform.Refresh PN$ = currform!PartNumber PN$ = Left$(PN$, 7) wh$ = currform!Warehouse Set MainSet = MainDB.OpenRecordset("RMSFILES#_PSNWP1A0", DB_OPEN_DYNASET) ' Create dynaset. MainSet.FindFirst "PRDNO = '" + PN$ + "'" If Not (MainSet.NoMatch) Then Gws$ = Format(itsaNull$(currform!GrossWt), "#.000") aws$ = Format(itsaNull$(currform!ActualWt), "#.000") matl$ = currform!Field113.Column(2) ' Mtl$ = itsaNull$(currform!Material) MainSet.Edit MainSet!netwt = aws$ MainSet!GRSwt = Gws$ MainSet![MATL#] = matl$ MainSet.Update End If pnn$ = Left$(PN$, 1) Select Case pnn$ Case "2" flnn$ = "KBBLP1A0-2" Case "8" flnn$ = "KBBLP1A0-8" Case "9" flnn$ = "KBBLP1A0-9" Case Else flnn$ = "KBBLP1A0" End Select Set MainSet = MainDB.OpenRecordset(flnn$, DB_OPEN_DYNASET) ' Create dynaset. MainSet.FindFirst "PRDNO = '" + PN$ + "'" Do If Not (MainSet.NoMatch) Then If MainSet!KBLWH = wh$ Then pps$ = currform!PartsPerSheet ppb$ = currform!PartsPerBlank MainSet.Edit MainSet!SSIZE3 = pps$ MainSet!BSIZE3 = ppb$ MainSet.Update Exit Do Else MainSet.FindNext "PRDNO = '" + PN$ + "'" End If Else Exit Do End If Loop End Sub Function LastInStr(st$, ins$) ' ' searches st$ for ins$ and returns the starting position ' of the last occurance of ins$. ' ' ' example: ' 123456789012345678901234 ' st$= "XXXXXXXXXXXXabcXXXabcXXX" ' ins$= "abc" ' ' LastInStr=19 ' ' lins = Len(ins$) lst = Len(st$) If (InStr(st$, ins$) = 0) Or (lins > lst) Then LastInStr = 0 Exit Function End If For ix = lst - lins + 1 To 1 Step -1 If Mid$(st$, ix, lins) = ins$ Then Exit For End If Next LastInStr = ix End Function Sub ds_add(dsType$, Oper$) fnd = 0 For i = 0 To 40 If Ds$(i) = "" Then fnd = 1 Exit For End If Next If fnd = 1 Then Ds$(i) = dsType$ + "~~" + Oper$ End If End Sub Sub Edit_The_Shear_Files() Open ShearsName For Input As #1 Line Input #1, Sheet1path$ Line Input #1, Sheet2path$ Close #1 Sheet1path$ = Trim$(Sheet1path$) Sheet2path$ = Trim$(Sheet2path$) FL$ = Trim$(currform!PartNumber) Rev$ = Right$(FL$, 1) If (Rev$ = "-") Or (InStr("0123456789", Rev$) <> 0) Then Rev$ = "" End If fx = Len(FL$) fl1$ = Sheet1path$ + "\" + Left$(FL$, fx - 1) + "." + Rev$ fl2$ = Sheet2path$ + "\" + Left$(FL$, fx - 1) + "." + Rev$ s = 0 On Error GoTo NoShear Open fl1$ For Input As #1 Close #1 On Error GoTo 0 If s = 0 Then x = Shell("NOTEPAD.EXE " + fl1$, 1) End If s = 0 On Error GoTo NoShear Open fl2$ For Input As #1 Close #1 On Error GoTo 0 If s = 0 Then x = Shell("NOTEPAD.EXE " + fl2$, 1) End If Exit Sub NoShear: s = 1 Resume Next End Sub Sub Elem_Add(PartN$, Oper$, ShType$) Dim DataShDB As Database, DataShSet As Recordset Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set search criteria. Set DataShDB = DBEngine.Workspaces(0).Databases(0) Set DataShSet = DataShDB.OpenRecordset("DataSheetQ1", DB_OPEN_DYNASET) If NoDataSheets% = 0 Then Exit Sub End If DataShSet.AddNew DataShSet!PartNumber = PartN$ DataShSet!Operation = Oper$ DataShSet!SheetType = ShType$ DataShSet!Generated = True DataShSet!Paperwork = Elem!(0) DataShSet!TotalSelectTime = Elem!(1) DataShSet!StandardParts = Elem!(2) DataShSet![StandardMinutes/part] = Elem!(3) DataShSet![pf&d] = Elem!(4) DataShSet![StandardHours/part] = Elem!(5) DataShSet!Elem1A = Elem!(6) DataShSet!Elem1V1 = Elem!(7) DataShSet!Elem1V2 = Elem!(8) DataShSet!Elem1V3 = Elem!(9) DataShSet!Elem2A = Elem!(10) DataShSet!Elem2V1 = Elem!(11) DataShSet!Elem2V2 = Elem!(12) DataShSet!Elem2V3 = Elem!(13) DataShSet!Elem3A = Elem!(14) DataShSet!Elem3V1 = Elem!(15) DataShSet!Elem3V2 = Elem!(16) DataShSet!Elem3V3 = Elem!(17) DataShSet!Elem4A = Elem!(18) DataShSet!Elem4V1 = Elem!(19) DataShSet!Elem4V2 = Elem!(20) DataShSet!Elem4V3 = Elem!(21) DataShSet!Elem5A = Elem!(22) DataShSet!Elem5V1 = Elem!(23) DataShSet!Elem5V2 = Elem!(24) DataShSet!Elem5V3 = Elem!(25) DataShSet!Elem6A = Elem!(26) DataShSet!Elem6V1 = Elem!(27) DataShSet!Elem6V2 = Elem!(28) DataShSet!Elem6V3 = Elem!(29) DataShSet!Elem7A = Elem!(30) DataShSet!Elem7V1 = Elem!(31) DataShSet!Elem7V2 = Elem!(32) DataShSet!Elem7V3 = Elem!(33) DataShSet!Elem8A = Elem!(34) DataShSet!Elem8V1 = Elem!(35) DataShSet!Elem8V2 = Elem!(36) DataShSet!Elem8V3 = Elem!(37) DataShSet!Elem9A = Elem!(38) DataShSet!Elem9V1 = Elem!(39) DataShSet!Elem9V2 = Elem!(40) DataShSet!Elem9V3 = Elem!(41) DataShSet!Elem10A = Elem!(42) DataShSet!Elem10V1 = Elem!(43) DataShSet!Elem10V2 = Elem!(44) DataShSet!Elem10V3 = Elem!(45) DataShSet!Elem11A = Elem!(46) DataShSet!Elem11V1 = Elem!(47) DataShSet!Elem11V2 = Elem!(48) DataShSet!Elem11V3 = Elem!(49) DataShSet!Elem12A = Elem!(50) DataShSet!Elem12V1 = Elem!(51) DataShSet!Elem12V2 = Elem!(52) DataShSet!Elem12V3 = Elem!(53) DataShSet.Update End Sub Sub Elem_ClearAllRecs(PartN$) Dim DataShDB As Database, DataShSet As Recordset If Not (OutPutData%) Then Exit Sub End If Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set search criteria. Set DataShDB = DBEngine.Workspaces(0).Databases(0) Set DataShSet = DataShDB.OpenRecordset("DataSheetQ1", DB_OPEN_DYNASET) DataShSet.FindFirst Criteria$ ' Find first occurrence. Do Until DataShSet.NoMatch ' Loop until no matching records. s$ = DataShSet!PartNumber If DataShSet!Generated = True Then DataShSet.Delete ' Delete it. End If DataShSet.FindNext Criteria$ ' Find next occurrence. Loop ' End of loop. End Sub Sub Elem_ClearArray() ' If Not (NoDataSheets%) Then For i = 0 To 53 Elem!(i) = 0 DoEvents Next ' endif End Sub Sub Elem_Del() Dim DataShDB As Database, DataShSet As Recordset PartN$ = currform!PartNumber Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set search criteria. Set DataShDB = DBEngine.Workspaces(0).Databases(0) Set DataShSet = DataShDB.OpenRecordset("DataSheetQ1", DB_OPEN_DYNASET) DataShSet.FindFirst Criteria$ ' Find first occurrence. Do Until DataShSet.NoMatch ' Loop until no matching records. Oper$ = DataShSet!Operation ShType$ = DataShSet!SheetType Cmp$ = ShType$ + "~~" + Oper$ fnd = 0 For i = 0 To 40 dx$ = Ds$(i) If dx$ = "" Then Exit For If dx$ = Cmp$ Then fnd = 1 Exit For End If Next If fnd = 0 Then If DataShSet!Generated = True Then DataShSet.Delete ' Delete it. End If End If DataShSet.FindNext Criteria$ ' Find next occurrence. Loop End Sub Sub ErrorMessages() If currform![CalculationStatus] = 0 Then currform!TextCalcErr.Visible = False Else currform!TextCalcErr.Visible = True Select Case currform![CalculationStatus] Case 1 currform!TextCalcErr.Caption = "Calculation Error" Case 2 currform!TextCalcErr.Caption = "Calculation Error Invalid 2nd Dim" Case 3 currform!TextCalcErr.Caption = "Calculation Error Invalid Sheet Width" Case 4 currform!TextCalcErr.Caption = "Calculation Parts/Sheet = 0" Case 5 currform!TextCalcErr.Caption = "Invalid PMI Trim Cut " Case 6 currform!TextCalcErr.Caption = "Unable to Calculate Zeros in entries" Case 7 currform!TextCalcErr.Caption = "Bad Record Information" Case 8 currform!TextCalcErr.Caption = "Unable to Calculate Cycle Time" Case 9 currform!TextCalcErr.Caption = "Cut Type Not Entered" Case 10 currform!TextCalcErr.Caption = "Invalid Part Width" Case 11 currform!TextCalcErr.Caption = "Invalid Material Selected" Case 12 currform!TextCalcErr.Caption = "Calculation Error Invalid 1nd Dim" Case 13 currform!TextCalcErr.Caption = "No Cut Type Selected" Case 14 currform!TextCalcErr.Caption = "Deburr Type Not Selected" Case 15 currform!TextCalcErr.Caption = "No Primary CNC Selected" Case 16 currform!TextCalcErr.Caption = "More Than One Primary CNC Selected" Case 17 currform!TextCalcErr.Caption = "C-1000 Must Use CB CL PB" Case 18 currform!TextCalcErr.Caption = "Invalid Work Center for Warehouse" Case 19 currform!TextCalcErr.Caption = "Deburr type cannot be Timer Saver if Metal type is Aluminized" Case 20 currform!TextCalcErr.Caption = "Part too small to run through Timer Saver" Case Else currform!TextCalcErr.Caption = "Unknown Error" End Select End If End Sub Sub Find_By_MakeNumber() PN$ = currform!PartNumber DocName = PrimaryScreen$ DoCmd.OpenForm DocName, , , LinkCriteria DoCmd.GoToControl "PartName" DoCmd.GoToControl "PhantomNumber" DoCmd.FindRecord PN$, A_ANYWHERE, False, A_DOWN, , , True DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, 9 End Sub Sub Find_By_PartNumber() PN$ = currform!PartNumber DocName = PrimaryScreen$ DoCmd.OpenForm DocName, , , LinkCriteria DoCmd.GoToControl "PartName" DoCmd.GoToControl "PartNumber" DoCmd.FindRecord PN$, A_ANYWHERE, False, acSearchAll, , , True DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, 9 End Sub Function FormitI$(A%, x$) l = Len(x$) FormitI$ = lpad$(Format$(A%, x$), l) End Function Function FormitS$(A!, x$) l = Len(x$) FormitS$ = lpad$(Format$(A!, x$), l) End Function Sub GOTOPARTNUMBER(PN$, PScreen$) DocName = PScreen$ DoCmd.OpenForm DocName, , , LinkCriteria DoCmd.GoToControl "PartName" DoCmd.GoToControl "PartNumber" DoCmd.FindRecord PN$, A_ANYWHERE, False, A_DOWN, True, , True End Sub Sub GrainFromRec() On Error GoTo CHKGRAIN Gd$ = currform!GrainDir On Error GoTo 0 Select Case Gd$ Case "Along First Dimension" currform!GrDirOpt = 1 Case "Along Second Dimension" currform!GrDirOpt = 2 Case "No Grain Direction" currform!GrDirOpt = 3 Case Else currform!GrDirOpt = 0 End Select gr_exit: Exit Sub CHKGRAIN: If Err = 94 Then currform!GrainDir = "No Grain Direction" currform!GrDirOpt = 3 Resume gr_exit End If Resume Next End Sub Sub HistoryR() If IsNull(currform!IssueNumber) Then currform!IssueNumber = " " If IsNull(currform!History) Then currform!History = " " If IsNull(currform!Reason) Then currform!Reason = " " currform!PreviousIssue = currform!IssueNumber currform!PreviousDate = currform!IssueDate isss = Val(itsaNull((currform!IssueNumber))) currform!IssueNumber = Trim$(Str$(isss + 1)) currform!IssueDate = Date$ H$ = currform!History H$ = "(" + Trim$(currform!Reason) + "/" + Date$ + ")" + H$ currform!History = RTrim$(rpad$(H$, 200)) End Sub Function instrl(A$, b$) la% = Len(A$) lb% = Len(b$) xp% = la% For i% = la% To 1 Step -1 va$ = Left$(Mid$(A$, i%), lb%) If va$ = b$ Then xp% = i% Exit For End If Next instrl = xp% End Function Function itsaNull$(variableField) If IsNull(variableField) Then IzzIt$ = "" Else IzzIt$ = variableField End If itsaNull$ = IzzIt$ End Function Function ItsAZero!(variableField) If IsNull(variableField) Then IzzIt1! = 0 Else IzzIt1! = variableField End If ItsAZero! = IzzIt1! End Function Function lpad$(A$, l) lpad$ = Right$(Space$(l) + A$, l) End Function Sub MakeProcesses() Dim AddnlQDB As Database, AddnlQSet As Recordset Dim AddnlDB As Database, AddnlSet As Recordset Dim MachQDB As Database, MachQSet As Recordset Dim MachNQDB As Database, MachNQSet As Recordset Dim PressBrk As Database, PressBrkSet As Recordset Dim PunchPress As Database, PunchPressSet As Recordset Dim PemPress As Database, PemPressSet As Recordset currform!txtCalcStat.Caption = "Entering Make Process" DoEvents PartN$ = currform![PartNumber] warehouses$ = currform![Warehouse] DescrW = 39 Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set search criteria. currform!txtCalcStat.Caption = "MP - Opening AddnlQ1" DoEvents Set AddnlQDB = DBEngine.Workspaces(0).Databases(0) Set AddnlQSet = AddnlQDB.OpenRecordset("AddnlQ1", DB_OPEN_DYNASET) ' Create dynaset. currform!txtCalcStat.Caption = "MP - Opening AddnlPROC" DoEvents Set AddnlDB = DBEngine.Workspaces(0).Databases(0) Set AddnlSet = AddnlQDB.OpenRecordset("AddnlPROC", DB_OPEN_TABLE) ' Create dynaset. currform!txtCalcStat.Caption = "MP - Opening PressBrakeQ1" DoEvents Set PressBrk = DBEngine.Workspaces(0).Databases(0) Set PressBrkSet = PressBrk.OpenRecordset("PressBrakeQ1", DB_OPEN_DYNASET) ' Create dynaset. currform!txtCalcStat.Caption = "MP - Opening PEMPressQ1" DoEvents Set PemPress = DBEngine.Workspaces(0).Databases(0) Set PemPressSet = PemPress.OpenRecordset("PEMPressQ1", DB_OPEN_DYNASET) ' Create dynaset. currform!txtCalcStat.Caption = "MP - Opening PunchPress" DoEvents Set PunchPress = DBEngine.Workspaces(0).Databases(0) Set PunchPressSet = PunchPress.OpenRecordset("PunchPress", DB_OPEN_TABLE) ' Create dynaset. PunchPressSet.Index = "Die" AddnlQSet.FindFirst Criteria$ ' Find first occurrence. Do Until AddnlQSet.NoMatch ' Loop until no matching records. Generated% = AddnlQSet!Generated ' Get Generation flag. s$ = AddnlQSet!PartNumber If Generated% = True Then ' if this is a generated record the delete it AddnlQSet.Delete ' Delete it. Else If warehouses$ = "90" Then If AddnlQSet!wc2 = "345" Or AddnlQSet!wc2 = "347" Then currform![CalculationStatus] = 18 Call ErrorMessages Exit Sub End If Else If AddnlQSet!wc2 = "302" Or AddnlQSet!wc2 = "304" Then currform![CalculationStatus] = 18 Call ErrorMessages Exit Sub End If End If End If AddnlQSet.FindNext Criteria$ ' Find next occurrence. DoEvents Loop ' End of loop. Set MachQDB = DBEngine.Workspaces(0).Databases(0) Set MachQSet = MachQDB.OpenRecordset("MachinesQ1", DB_OPEN_DYNASET) ' Create dynaset. 'Set MachQSet = StMachQ2Set Set MachNQDB = DBEngine.Workspaces(0).Databases(0) Set MachNQSet = MachNQDB.OpenRecordset("MachineNames", DB_OPEN_TABLE) ' Create dynaset. 'Set MachNQSet = StMachNamesSet MachNQSet.Index = "PrimaryKey" For i = 0 To 40 ' clear the data sheet requirements array Ds$(i) = "" Next PMachine$ = "" MachQSet.FindFirst Criteria$ ' Find first occurrence. currform!txtCalcStat.Caption = "MP - look for primary machine" Do Until MachQSet.NoMatch ' Loop until no matching records. If MachQSet!Prime = True Then If MachQSet!Tool <> "SHR" Then If PMachine$ <> "" Then currform![CalculationStatus] = 16 Call ErrorMessages Exit Sub End If PMachine$ = MachQSet!MachineName PWC1$ = MachQSet!Tool PCTime! = MachQSet!CycleTime End If End If MachQSet.FindNext Criteria$ ' Find next occurrence. DoEvents Loop If (PMachine$ = "") And (Multi$ <> "NO CNC") And (Multi$ <> "BLANK") Then currform![CalculationStatus] = 15 Call ErrorMessages Exit Sub End If If Left$(PMachine$, 3) = "C-1" And currform!PressBrake <> 1 Then If currform!PressBrake <> 7 Then currform![CalculationStatus] = 17 Call ErrorMessages Exit Sub End If End If If (Multi$ <> "NO CNC") And (Multi$ <> "BLANK") Then Call Det_CNC_Highest_Runtime(PartN$, CNCTime!, r$) End If GoSub CheckTheDeburrStuff If Not (PurchaseBlank%) Then If (First_Dim! <> Sheet_Length!) Or (Second_dim! <> Sheet_Width!) Then Call Det_Shear_Standard(1, First_Cut_Std, Second_Cut_Std, Multiple_Cut_Std, Multiple_Cut_Labor) End If End If currform!txtCalcStat.Caption = "MP - generate processes" DoEvents OpCode% = 10 Select Case Multi$ Case "SINGLE" GoSub Shear1 GoSub Shear2 If currform!PunchPressOption.Visible = True Then If currform!PunchPressOption = 1 Then GoSub PunchPress End If End If GoSub CNCOp If currform!PunchPressOption.Visible = True Then If currform!PunchPressOption = 2 Then GoSub PunchPress End If End If Case "MULTIPLE" GoSub Shear1 If ExtraShear% Then ESTimes% = True GoSub Shear2 ESTimes% = False End If GoSub CNCOp If SecondShear Then GoSub Shear2 End If Case "LASER", "LASER/SHEAR", "SLUG" If (First_Dim! <> Sheet_Length!) Or (Second_dim! <> Sheet_Width!) Then GoSub Shear1 If (ExtraShear%) Or (Multi$ = "LASER/SHEAR") Then ESTimes% = True GoSub Shear2 ESTimes% = False End If End If GoSub CNCOp Case "SALVAGNINI" GoSub CNCOp Case "NO CNC" GoSub Shear1 GoSub Shear2 GoSub PunchPress Case "BLANK" GoSub Shear1 Case Else End Select GoSub DeBurrOut If currform!PemBefore = True Then GoSub PemPress GoSub PressBrake Else GoSub PressBrake GoSub PemPress End If If OutPutData% Then currform.Refresh Call renumber If NoDataSheets% = 1 Then Call Elem_Del End If currform.Refresh Call ErrorMessages End If Exit Sub AddAP: ' Input Parms: OpCode%, PartN$, Descr$, wc1$-wc4$, machine$, ctime!, Rstd! opc$ = Opps$(OpCode%) AddnlSet.AddNew AddnlSet!PartNumber = PartN$ AddnlSet!OpCode = opc$ AddnlSet!Generated = True AddnlSet!Description = DESCR$ AddnlSet!wc1 = lpad$(wc1$, 3) AddnlSet!wc2 = lpad$(wc2$, 3) AddnlSet!wc3 = lpad$(wc3$, 3) AddnlSet!wc4 = lpad$(wc4$, 3) AddnlSet!Machine = rpad$(Machine$, 30) AddnlSet!CycleTime = ctime! AddnlSet!RunStd = Rstd! AddnlSet.Update Return CNCOp: Select Case Multi$ Case "SINGLE" If vb$ = "" Then DESCR$ = rpad$("NOTCH & PIERCE COMPLETE", DescrW) Call Add_Shear_Verbage(DESCR$) Else DESCR$ = vb$ End If Case "MULTIPLE" If vb$ = "" Then DESCR$ = rpad$("NOTCH & PIERCE COMPLETE MULTIPLE", DescrW) Call Add_Shear_Verbage(DESCR$) Else DESCR$ = vb$ End If Case "SALVAGNINI" DESCR$ = rpad$("LOAD / UNLOAD SALVAGNINI", DescrW) Case "LASER", "LASER/SHEAR", "SLUG" If (Multi$ = "SLUG") Then slugispart% = True vb$ = "" Else slugispart% = False End If If vb$ = "" Then prm$ = Left$(PMachine$, 3) Select Case prm$ Case "C-1", "C-2", "C-3", "C-4", "C-5", "C-6", "C-7", "C-8", "C-9", "V-1", "V-2", "V-4", "C10" DESCR$ = rpad$("NOTCH & PIERCE COMPLETE - SLUG IS PART", DescrW) Call Add_Shear_Verbage(DESCR$) slugispart% = True Case Else If (Multi$ = "SLUG") Then DESCR$ = rpad$("NOTCH & PIERCE COMPLETE - SLUG IS PART", DescrW) Call Add_Shear_Verbage(DESCR$) slugispart% = True Else DESCR$ = rpad$("CUT COMPLETE MULTIPLE", DescrW) Call Add_Shear_Verbage(DESCR$) End If End Select Else DESCR$ = vb$ End If If (Multi$ = "SLUG") Then slugispart% = True Case Else DESCR$ = rpad$("NOTCH & PIERCE COMPLETE", DescrW) GoSub DeburrIn Call Add_Shear_Verbage(DESCR$) DESCR$ = DESCR$ + db$ End Select ' ' If (Multi$ = "MULTIPLE") Or (Multi$ = "LASER") Or (Multi$ = "SLUG") Or (Multi$ = "LASER/SHEAR") Then DESCR$ = DESCR$ + rpad$("(" + Format$(Parts_Per_blank!, "####0") + " PARTS/BLANK)", DescrW) End If wc1$ = " ": wc2$ = " ": wc3$ = " ": wc4$ = " ": Machine$ = " " DESCR$ = DESCR$ + rpad$("CNC's:", DescrW) MachQSet.FindFirst Criteria$ ' Find first occurrence. STDRD$ = "STD" If (Not (SecondShear)) And (Multi$ = "MULTIPLE") Then If InStr(MachinesWithShears$, Left$(PMachine$, 3)) <> 0 Then STDRD$ = "SNS" End If End If Do Until MachQSet.NoMatch ' Loop until no matching records. If (MachQSet!Prime = True) Then MachNQSet.MoveFirst MName$ = MachQSet!MachineName MachNQSet.Seek "=", MName$ If Not (MachNQSet.NoMatch) Then wc2$ = MachNQSet!wc2 If wc2$ = "302" Then wc2$ = warehousewc$ wc3$ = MachNQSet!wc3 wc4$ = MachNQSet!wc4 End If End If If MachQSet!Tool <> "***" Then Toool$ = MachQSet!Tool If Toool$ = "STD" Then If InStr(MachinesWithShears$, Left$(MachQSet!MachineName, 3)) = 0 Then Toool$ = STDRD$ End If End If dd$ = "(" + MachQSet!MachineName + "/" + Toool$ DESCR$ = DESCR$ + rpad$(dd$ + "/" + Format$(MachQSet!CycleTime, "#####0.0") + ")", DescrW) End If MachQSet.FindNext Criteria$ ' Find next occurrence. Loop If ((Multi$ = "LASER") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG")) And Not (slugispart%) Then Call Det_LASER_Standard(PartN$, Rstd!, ctime!) Call ds_add("LASER", " ") ElseIf (Multi$ = "SALVAGNINI") And Not (slugispart%) Then Call Det_Salvagnini_Standard(PartN$, Rstd!, ctime!) Call ds_add("SALVAGNINI", " ") Else Call Det_CNC_Highest_Runtime(PartN$, ctime!, r$) Call Det_CNC_Standard(Rstd!, ctime!, r$) Call ds_add("CNC", " ") End If Machine$ = PMachine$ wc1$ = PWC1$ GoSub AddAP OpCode% = (OpCode% \ 10) + 1 OpCode% = OpCode% * 10 If ((Left$(PMachine$, 2) = "T-") Or (Left$(PMachine$, 3) = "L-2")) And (slugispart% = False) Then If PMachine = "L-2 3030 POT" Then Call Det_Shake("P", Rstd!) Else If MetalPart$ = "8111095" Or MetalPart$ = "8111126" Or MetalPart$ = "8110854" Or MetalPart$ = "8110799" Or MetalPart$ = "8111171" Or MetalPart$ = "8111172" Or MetalPart$ = "8110042" Then Call Det_Shake("FM", Rstd!) Else Call Det_Shake("F", Rstd!) End If End If Select Case Left$(PMachine$, 3) Case "T-1" wc2$ = "302" 'was 330 SG wc3$ = "071" 'was 017 SG wc4$ = "450" Case "T-2" wc2$ = "302" 'was 330 SG wc3$ = "072" 'was 018 SG wc4$ = "451" Case "T-3" wc2$ = "302" 'was 330 SG wc3$ = "073" 'was 019 SG wc4$ = "452" Case "T-4" wc2$ = "302" 'was 330 SG wc3$ = "074" 'was 020 SG wc4$ = "453" Case "L-2" wc2$ = "312" wc3$ = "119" wc4$ = "519" Case Else End Select wc1$ = "" Machine$ = "SHAKE" DESCR$ = "SHAKE AND BREAK PARTS FROM SKELETON" ctime! = 0 'Input Parms: OpCode%, PartN$, Descr$, wc1$-wc4$, machine$, ctime!, Rstd! GoSub AddAP OpCode% = (OpCode% \ 10) + 1 OpCode% = OpCode% * 10 End If Return Shear1: ' ' First CUT ' If PurchaseBlank% Then Return End If Call ds_add("SHEAR", "FRST") ctime! = 0 Rstd! = 0 If FirstCutDir% = 2 Then DESCR$ = "USING PMI BLOCK TO " + Format$(Second_dim!, "####0.000") + " X " fc! = Second_dim! sc! = First_Dim! Else DESCR$ = "USING PMI BLOCK TO " + Format$(First_Dim!, "####0.000") + " X " fc! = First_Dim! sc! = Second_dim! End If If ExtraShear% Then DESCR$ = "USING PMI BLOCK TO " + Format$(Second_dim!, "####0.000") + " X " fc! = Second_dim! sc! = First_Dim! End If DESCR$ = rpad$(DESCR$ + Format$(Sheet_Width!, "####0.000"), DescrW) DESCR$ = DESCR$ + rpad$("(" + Format$(Blocks_Per_Sheet!, "###0") + " BLOCKS/SHEET)", DescrW) If Location% = 1 Then If warehousewc$ = "302" Then wc1$ = " ": wc2$ = warehousewc$: wc3$ = "007": wc4$ = "007": Machine$ = "SHEAR 10" ShearWC$ = "007" Else wc1$ = " ": wc2$ = warehousewc$: wc3$ = "007": wc4$ = "359": Machine$ = "SHEAR 10" ShearWC$ = "007" End If ElseIf Location% = 2 Then If warehousewc$ = "302" Then wc1$ = " ": wc2$ = warehousewc$: wc3$ = "009": wc4$ = "009": Machine$ = "SHEAR 10" ShearWC$ = "009" Else wc1$ = " ": wc2$ = warehousewc$: wc3$ = "009": wc4$ = "360": Machine$ = "SHEAR 10" ShearWC$ = "009" ' changed the 007's to 009 End If Else Pm$ = Left$(PMachine$, 3) If ((Pm$ = "C-1") Or (Pm$ = "C-2")) And (warehousewc$ = "302") Then wc1$ = " ": wc2$ = warehousewc$: wc3$ = "009": wc4$ = "009": Machine$ = "SHEAR 10" ShearWC$ = "009" Else wc1$ = " ": wc2$ = warehousewc$: wc3$ = "009": wc4$ = "009": Machine$ = "SHEAR 10" ShearWC$ = "009" ' changed the 007's to 009 End If End If If (Denting% = 1) Or (Denting% = 3) Then nt$ = "_BLOCK " + Trim$(Str$(Blocks_Per_Sheet! + 1)) + " UNUSABLE DUE TO DENTING)" DESCR$ = DESCR$ + "(NOTE:" Call AddDescr(DESCR$, nt$, DescrW) End If FCM$ = wc3$ Rstd! = First_Cut_Std GoSub AddAP 'OpCode% = OpCode% + 1 'Descr$ = rpad$("SHEAR HELPER", DescrW) 'wc1$ = " ": wc2$ = warehousewc$: wc3$ = "010": wc4$ = "010": Machine$ = " " 'Rstd! = First_Cut_Std 'GoSub AddAP 'If Fc! <= 12 Then ' OpCode% = OpCode% + 1 ' Descr$ = rpad$("OFFALL LABOR", DescrW) ' wc1$ = " ": wc2$ = warehousewc$: wc3$ = ShearWC$: wc4$ = "027": Machine$ = " " ' Rstd! = First_Cut_Std ' GoSub AddAP 'End If OpCode% = (OpCode% \ 10) + 1 OpCode% = OpCode% * 10 Call Shear1FILE Return Shear2: ' ' Second Cut ' If PurchaseBlank% Then Return End If Punch$ = currform!PunchNumber If (Multi$ = "NO CNC") And (Punch$ <> "!NONE!") And (currform!PunchPressOption = 2) Then Return End If ctime! = 0 Rstd! = 0 Bottom_Trim_Cut! = (currform![BotTrimCut]) TOP_TRIM_CUT! = (currform![TopTrimCut]) If (Multi$ = "MULTIPLE") And Not (ESTimes%) Then DESCR$ = rpad$("USING PMI SHEAR OFF EXCESS-" + Format$(Bottom_Trim_Cut!, "####0.00"), DescrW) dx$ = "BOTTOM" If TOP_TRIM_CUT! > 0 Then dx$ = dx$ + "/" + Format$(TOP_TRIM_CUT!, "####0.00") + " TOP" End If DESCR$ = DESCR$ + rpad$(dx$ + " (" + Format$(Parts_Per_blank!, "####0") + " PARTS/BLANK)", DescrW) fc! = Second_dim! If (Denting% = 2) Or (Denting% = 3) Then nt$ = "_BLANK " + Trim$(Str$(Blanks_Per_Block! + 1)) + " UNUSABLE DUE TO DENTING)" DESCR$ = DESCR$ + "(NOTE:" Call AddDescr(DESCR$, nt$, DescrW) End If If warehousewc$ = "302" Then wc1$ = " ": wc2$ = warehousewc$: wc3$ = "009": wc4$ = " ": Machine$ = "SHEAR 10" Else wc1$ = " ": wc2$ = warehousewc$: wc3$ = "007": wc4$ = " ": Machine$ = "SHEAR 10" End If Rstd! = Multiple_Cut_Std Call ds_add("SHEAR", "MULT") GoSub AddAP Else If ESTimes% Then DESCR$ = rpad$("USING PMI SQUARE END OF BLOCK,", DescrW) DESCR$ = DESCR$ + rpad$("SHEAR TO " + Format$(sc!, "####0.000") + " X " + Format$(fc!, "####0.000"), DescrW) DESCR$ = DESCR$ + rpad$("(" + Format$(Blanks_Per_Block!, "####0") + " BLANKS/BLOCK)", DescrW) Rstd! = Second_Cut_Std Else DESCR$ = rpad$("USING PMI SQUARE END OF BLOCK, ", DescrW) DESCR$ = DESCR$ + rpad$("SHEAR TO " + Format$(sc!, "####0.000") + " X " + Format$(fc!, "####0.000"), DescrW) DESCR$ = DESCR$ + rpad$("(" + Format$(Blanks_Per_Block!, "####0") + " BLANKS/BLOCK)", DescrW) Rstd! = Second_Cut_Std End If If (Denting% = 2) Or (Denting% = 3) Then nt$ = "_BLANK " + Trim$(Str$(Blanks_Per_Block! + 1)) + " UNUSABLE DUE TO DENTING)" DESCR$ = DESCR$ + "(NOTE:" Call AddDescr(DESCR$, nt$, DescrW) End If If (FCM$ = "009") And (warehousewc$ = "302") Then wc1$ = " ": wc2$ = warehousewc$: wc3$ = "009": wc4$ = " ": Machine$ = "SHEAR 10" GoSub AddAP Else wc1$ = " ": wc2$ = warehousewc$: wc3$ = "007": wc4$ = " ": Machine$ = "SHEAR 10" GoSub AddAP End If Call ds_add("SHEAR", "SCND") End If ' OpCode% = OpCode% + 1 ' Descr$ = rpad$("SHEAR HELPER", DescrW) ' wc1$ = " ": wc2$ = warehousewc$: wc3$ = "010": wc4$ = " ": Machine$ = " " ' GoSub AddAP OpCode% = (OpCode% \ 10) + 1 OpCode% = OpCode% * 10 Call Shear2FILE Return DeBurrOut: If ((TypeDeburr$ = "OUTSIDE") Or (completedeburr% <> 0)) And (TypeDeburr$ <> "NONE") Then If InStr(TypeDeburr$, "OUTSIDE") <> 0 Then completedeburr% = 2 End If Celltype$ = UCase$(currform![CellDeburrTypes]) ctime! = 0: Rstd! = 0 If (Left$(PMachine$, 3) = "L-2") Then 'took out (Left$(PMachine$, 2) = "T-") Or "SG" wc2$ = "330" If (Left$(PMachine$, 3) = "L-2") Then wc2$ = "312" End If Else Select Case PMachine$ Case "S4/Shear and Unload", "S4 and Unload" wc2$ = "365" 'WAS 302 SG Case "P4 and Unload", "S4/P4 and Unload", "S4/P4 Inline and Unl" wc2$ = "365" Case Else wc2$ = warehousewc$ End Select End If wc1$ = " ": wc3$ = "016": wc4$ = "016": Machine$ = "DEBURR" If Multi$ = "MULTIPLE" Then If completedeburr% = 1 Then TOP_TRIM_CUT! = (currform![TopTrimCut]) If TOP_TRIM_CUT! = 0 Then Select Case Celltype Case "HAND DEBURR" DESCR$ = rpad$("DEBURR EDGES w/ HAND GRINDER", DescrW) Call Det_HandDeburr(hdb4!, Rstd!, 3) Call ds_add("HANDDEBURR", "MEdg") Case "TIME SAVER" If Mt$ = "TIMESAVER" Then DESCR$ = rpad$("DEBURR EDGES USING TIMESAVER", DescrW) Call Det_TimeSaver_Labor(mts!, Rstd!, False, BadTs%) Call ds_add("TIMESAVER", "SHRD") Else Call Det_Pedestal_Grinder_Standard(Actual_PartHeight, Actual_PartWidth, 2, Rstd!, 1!) ' sidetype=2 DESCR$ = rpad$("DEBURR (1) EDGE w/ PEDESTAL GRINDER", DescrW) Call ds_add("PEDESTAL", "1Edg") End If Case Else Call Det_Pedestal_Grinder_Standard(Actual_PartHeight, Actual_PartWidth, 2, Rstd!, 1!) ' sidetype=2 DESCR$ = rpad$("DEBURR (1) EDGE w/ PEDESTAL GRINDER", DescrW) Call ds_add("PEDESTAL", "1Edg") End Select Else Select Case Celltype Case "HAND DEBURR" DESCR$ = rpad$("DEBURR EDGES w/ HAND GRINDER", DescrW) Call Det_HandDeburr(hdb4!, Rstd!, 3) Call ds_add("HANDDEBURR", "MEdg") Case "TIME SAVER" If Mt$ = "TIMESAVER" Then DESCR$ = rpad$("DEBURR EDGES USING TIMESAVER", DescrW) Call Det_TimeSaver_Labor(mts!, Rstd!, False, BadTs%) Call ds_add("TIMESAVER", "SHRD") Else Call Det_Pedestal_Grinder_Standard(Actual_PartHeight, Actual_PartWidth, 4, Rstd!, 1!) ' sidetype=22 DESCR$ = rpad$("DEBURR (2) EDGES w/ PEDESTAL GRINDER", DescrW) Call ds_add("PEDESTAL", "2Edg") End If Case Else Call Det_Pedestal_Grinder_Standard(Actual_PartHeight, Actual_PartWidth, 4, Rstd!, 1!) ' sidetype=22 DESCR$ = rpad$("DEBURR (2) EDGES w/ PEDESTAL GRINDER", DescrW) Call ds_add("PEDESTAL", "2Edg") End Select End If Else Select Case Celltype Case "HAND DEBURR" DESCR$ = rpad$("DEBURR EDGES w/ HAND GRINDER", DescrW) Call Det_HandDeburr(hdb4!, Rstd!, 3) Call ds_add("HANDDEBURR", "MEdg") Case "TIME SAVER" If Mt$ = "TIMESAVER" Then DESCR$ = rpad$("DEBURR EDGES USING TIMESAVER", DescrW) Call Det_TimeSaver_Labor(mts!, Rstd!, False, BadTs%) Call ds_add("TIMESAVER", "SHRD") Else DESCR$ = rpad$("DEBURR EDGES w/ PEDESTAL GRINDER", DescrW) Call Det_Pedestal_Grinder_Standard(Actual_PartHeight, Actual_PartWidth, 8, Rstd!, 1!) ' sidetype=1122 Call ds_add("PEDESTAL", "4Edg") End If Case Else DESCR$ = rpad$("DEBURR EDGES w/ PEDESTAL GRINDER", DescrW) Call Det_Pedestal_Grinder_Standard(Actual_PartHeight, Actual_PartWidth, 8, Rstd!, 1!) ' sidetype=1122 Call ds_add("PEDESTAL", "4Edg") End Select End If Else Select Case Celltype Case "HAND DEBURR" DESCR$ = rpad$("DEBURR EDGES w/ HAND GRINDER", DescrW) Call Det_HandDeburr(hdb4!, Rstd!, 3) Call ds_add("HANDDEBURR", "MEdg") Case "TIME SAVER" If Mt$ = "TIMESAVER" Then DESCR$ = rpad$("DEBURR EDGES USING TIMESAVER", DescrW) Call Det_TimeSaver_Labor(mts!, Rstd!, False, BadTs%) Call ds_add("TIMESAVER", "SHRD") Else DESCR$ = rpad$("DEBURR EDGES w/ PEDESTAL GRINDER", DescrW) Call Det_Pedestal_Grinder_Standard(Actual_PartHeight, Actual_PartWidth, 8, Rstd!, 1!) ' sidetype=1122 Call ds_add("PEDESTAL", "4Edg") End If Case Else DESCR$ = rpad$("DEBURR EDGES w/ PEDESTAL GRINDER", DescrW) Call Det_Pedestal_Grinder_Standard(Actual_PartHeight, Actual_PartWidth, 8, Rstd!, 1!) ' sidetype=1122 Call ds_add("PEDESTAL", "4Edg") End Select End If GoSub AddAP OpCode% = (OpCode% \ 10) + 1 OpCode% = OpCode% * 10 End If Return DeburrIn: db$ = "" If InStr(TypeDeburr$, "WITHIN") <> 0 Then db$ = " & DEBURR W/HAND GRINDER" If (InStr(MetalName$, "COLD ROLL") <> 0) Or (InStr(MetalName$, "S/S") <> 0) Then ' NOT aluminized db$ = db$ + " & AEM MACHINE" End If End If If db$ <> "" Then db$ = rpad$(db$, DescrW) Return PressBrake: If currform!PressBrake <> "1" Then PressBrkSet.FindFirst Criteria$ ' Find first occurrence. If Not (PressBrkSet.NoMatch) Then opc$ = itsaNull$(PressBrkSet!OpCode) End If PBDescr$ = "FORM_" PBG1 = 0 totalhits = 0 PrbrkOps = 0 Do Until PressBrkSet.NoMatch ' Loop until no matching records. Op$ = itsaNull$(PressBrkSet!OpCode) If Op$ <> "" Then angl$ = Trim$(UCase$(PressBrkSet!Angle)) AnglC$ = Left$(angl$, 1) AnglR$ = Mid$(angl$, 2) AnglR$ = Trim$(Str$(Val(AnglR$))) Commnt$ = itsaNull$(PressBrkSet!comment) If Len(Commnt$) <> 0 Then Commnt$ = " " + Commnt$ End If If Op$ = opc$ Then PBG1 = 1 Else PrbrkOps = PrbrkOps + 1 GoSub MakePressBrk opc$ = Op$ PBG1 = 1 End If totalhits = totalhits + PressBrkSet!hits Select Case AnglC$ Case "S" 'spank dd$ = "(" + Trim$(Str$(PressBrkSet!Breaks)) + ") SPANK TO " + AnglR$ + " DEGS" + Commnt$ + "~~~" Call AddDescr(PBDescr$, dd$, DescrW) Case "O" 'offset dd$ = "(" + Trim$(Str$(PressBrkSet!Breaks)) + ") " + AnglR$ + Chr$(34) + " OFFSET" + Commnt$ + "~~~" Call AddDescr(PBDescr$, dd$, DescrW) Case "R" 'radius dd$ = "(" + Trim$(Str$(PressBrkSet!Breaks)) + ") " + AnglR$ + Chr$(34) + " RADIUS" + Commnt$ + "~~~" Call AddDescr(PBDescr$, dd$, DescrW) Case "F" 'form If Len(angl$) = 1 Then dd$ = "(" + Trim$(Str$(PressBrkSet!Breaks)) + ") " + Commnt$ + "~~~" Call AddDescr(PBDescr$, dd$, DescrW) Else dd$ = "(" + Trim$(Str$(PressBrkSet!Breaks)) + ") @ " + AnglR$ + " DEGS" + Commnt$ + "~~~" Call AddDescr(PBDescr$, dd$, DescrW) End If Case "D" 'die setup dd$ = AnglR$ + " DIE SETUP" + Commnt$ + "\\\" Call AddDescr(PBDescr$, dd$, DescrW) Case "C" 'comment dd$ = "(" + Trim$(Commnt$) + ")\\\" Call AddDescr(PBDescr$, dd$, DescrW) End Select End If PressBrkSet.FindNext Criteria$ ' Find next occurrence. Loop ' End of loop. If PBG1 = 1 Then PrbrkOps = PrbrkOps + 1 GoSub MakePressBrk End If End If Return MakePressBrk: cnt = 0: b = 0: A = 0 Do While InStr(PBDescr$, "~~~") <> 0 b = A A = InStr(PBDescr$, "~~~") Mid$(PBDescr$, A, 3) = ", " cnt = cnt + 1 Loop If cnt > 0 Then If b <> 0 Then Mid$(PBDescr$, A, 3) = " / " Mid$(PBDescr$, b, 3) = " & " Else Mid$(PBDescr$, A, 3) = " & " End If If cnt = 1 Then Mid$(PBDescr$, A, 3) = " / " End If End If dd$ = "(" + LTrim$(Str$(totalhits)) + "_TOTAL_HITS)" Call AddDescr(PBDescr$, dd$, DescrW) Do While InStr(PBDescr$, "\\\") <> 0 A = InStr(PBDescr$, "\\\") Mid$(PBDescr$, A, 3) = " / " cnt = cnt + 1 Loop DESCR$ = RTrim$(PBDescr$) wc1$ = " " ctime! = 0 Call DET_PressBrake_Standard(Rstd!, totalhits, wc2$, wc3$, wc4$, Machine$) 'If there is a seperate operation on routing for panel bender it changes the work center to a regular pressbrake. SG 5/3/2024 If Machine$ = "Trumpf 7020 PB" And PrbrkOps > 1 Then wc2$ = "302" wc3$ = "060" wc4$ = "235" Machine$ = "Trumpf 5130 #28" End If GoSub AddAP OpCode% = (OpCode% \ 10) + 1 OpCode% = OpCode% * 10 totalhits = 0 PBDescr$ = "FORM_" PBG1 = 0 Return PemPress: If currform!Pems = True Then ctime! = 0 Rstd! = 0 PemPressSet.FindFirst Criteria$ ' Find first occurrence. Do Until PemPressSet.NoMatch ' Loop until no matching records. Op$ = itsaNull$(PemPressSet!OpCode) hits$ = itsaNull$(PemPressSet!hits) Pemn$ = itsaNull$(PemPressSet!PemNumber) StudS$ = itsaNull$(PemPressSet!Studsize) AnvilS$ = itsaNull$(PemPressSet!Anvil) PunchS$ = itsaNull$(PemPressSet!Punch) Machine$ = UCase$(itsaNull$(PemPressSet!AutoManual)) wc1$ = " " wc2$ = itsaNull$(PemPressSet!wc2) wc3$ = itsaNull$(PemPressSet!wc3) wc4$ = itsaNull$(PemPressSet!wc4) DESCR$ = "INSTALL (" + hits$ + ") " + Pemn$ + " USING " + PunchS$ + " PUNCH AND " + AnvilS$ + " ANVIL PER DRAWING" ctime! = 0 hitd = Val(hits$) Gw! = Gw! Call DET_PEM_Standard(Rstd!, hitd, wc2$, wc3$, wc4$, Machine$) GoSub AddAP OpCode% = (OpCode% \ 10) + 1 OpCode% = OpCode% * 10 PemPressSet.FindNext Criteria$ ' Find next occurrence. Loop ' End of loop. End If Return PunchPress: ctime! = 0 Rstd! = 0 Punch$ = currform!PunchNumber Crit$ = "Die Number = " + Punch$ PunchPressSet.Seek "=", Punch$ ' Find first occurrence. If (Not (PunchPressSet.NoMatch)) And (Not (PunchPressSet.EOF)) And (Punch$ <> "!NONE!") Then If IsNull(PunchPressSet!Location) Then PUNCHLOC$ = " " Else PUNCHLOC$ = PunchPressSet!Location End If If IsNull(PunchPressSet!Machine) Then PunchMach$ = " " Else PunchMach$ = PunchPressSet!Machine End If If IsNull(PunchPressSet![Safety Device]) Then PunchSafe$ = " " Else PunchSafe$ = PunchPressSet![Safety Device] End If If IsNull(PunchPressSet!comment) Then PunchCmnt$ = " " Else PunchCmnt$ = PunchPressSet!comment End If If PunchPressSet![Forming Die] Then DESCR$ = rpad$("NOTCH, PIERCE, & FORM COMPLETE_", DescrW) Else DESCR$ = rpad$("NOTCH & PIERCE COMPLETE_", DescrW) End If If PunchPressSet![Changeover Die] Then ChangeOver$ = "/(NOTE: VERIFY DIE IS SET FOR PART)/" Else ChangeOver$ = "" End If If (currform!CutType = "No CNC") And (Parts_per_strip! > 1) Then dd$ = "(" + Trim$(Str$(Parts_per_strip!)) + " PARTS/STRIP)" Call AddDescr(DESCR$, dd$, DescrW) End If ' ' ' dd$ = " DIE #: " + Trim$(Punch$) + " /LOCATION:" + Trim$(PUNCHLOC$) Call AddDescr(DESCR$, dd$, DescrW) dd$ = "/" + Trim$(PunchMach$) + " /" + Trim$(PunchSafe$) Call AddDescr(DESCR$, dd$, DescrW) dd$ = ChangeOver$ Call AddDescr(DESCR$, dd$, DescrW) dd$ = PunchCmnt$ Call AddDescr(DESCR$, dd$, DescrW) Rstd! = ItsAZero!(currform!PunchStd) ' Call Det_PunchPress(Rstd!, CTime!, R$) If Left$(PunchMach$, 3) <> "150" Then wc1$ = " ": wc2$ = warehousewc$: wc3$ = "006": wc4$ = "006": Machine$ = PunchMach$ Else wc1$ = " ": wc2$ = warehousewc$: wc3$ = "005": wc4$ = "005": Machine$ = PunchMach$ End If GoSub AddAP OpCode% = (OpCode% \ 10) + 1 OpCode% = OpCode% * 10 End If Return CheckTheDeburrStuff: ' ' This routine sets up the dbtype array with 1's and 0's depending on whether or not the celltypedeburr ' should be calculated or not. ' ' ' if single then ' 2,11,12 ' done ' endif ' ' if top<>bot then trim cut ' only 1 & 15 ' done ' endif ' ' if (top<>2) and (top<>2.25) then ' only 1 & 15 ' done ' endif ' ' if >=5 and (S/S or C/R) then ' 1,3-10,13-16 ' else ' 1,3-9,13-14 ' endif ' done ' ' ' CNC time ' ' calc shear ' ' calc Mult Hnd DB ' ' calc timesaver ' ' calc hand db1 ' calc hand db2 ' calc hand db4 ' ' calc pdstl db1 ' calc pdstl db2 ' calc pdstl db4 ' ' ' ' Init the dbtype table to zeros ' For i = 1 To 16 dbtype!(i, 0) = 0 Next ' ' ' Determine if the timesaver can be used to deburr. ' ' SecondShear = True If ((TOP_TRIM_CUT! = 0) Or (TOP_TRIM_CUT! = Bottom_Trim_Cut!)) And ((Bottom_Trim_Cut! = 2) Or (Bottom_Trim_Cut! = 2.25)) Then SecondShear = False End If If (InStr(MetalName$, "COLD ROLL") <> 0) Or (InStr(MetalName$, "S/S") <> 0) Then ' NOT aluminized If ((currform!ActualPartHeight < 5) And (currform!ActualPartWidth < 5)) Then ' too small for timesaver Mt$ = "NO TIMESAVER" Else Mt$ = "TIMESAVER" End If Else Mt$ = "NO TIMESAVER" End If ' ' ' Obtain the Primary Machine name. ' ' PrimeType$ = Left$(PMachine$, 3) ' ' ' Single Part Deciphering ' ' If (Multi$ = "SINGLE") Or (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then If InStr(MachinesWithShears$, PrimeType$) <> 0 Then dbtype!(2, 0) = 1 dbtype!(11, 0) = 1 dbtype!(12, 0) = 1 Else dbtype!(2, 0) = 1 dbtype!(11, 0) = 1 End If If (InStr(TypeDeburr$, "OUTSIDE") <> 0) Or (InStr(TypeDeburr$, "NONE") <> 0) Then dbtype!(2, 0) = 0 dbtype!(11, 0) = 0 dbtype!(12, 0) = 0 End If ' ' ' Multiple and Laser Part Deciphering ' ' Else If InStr(MachinesWithShears$, PrimeType$) <> 0 Then If Actual_PartHeight < 1.75 Then ' Minimum part length for CNC shear SecondShear = True dbtype!(1, 0) = 1 dbtype!(15, 0) = 1 Else dbtype!(1, 0) = 1 dbtype!(3, 0) = 1 dbtype!(4, 0) = 1 dbtype!(5, 0) = 1 dbtype!(6, 0) = 1 dbtype!(8, 0) = 1 dbtype!(9, 0) = 1 dbtype!(10, 0) = 1 dbtype!(13, 0) = 1 dbtype!(14, 0) = 1 dbtype!(16, 0) = 1 dbtype!(15, 0) = 1 If TOP_TRIM_CUT! > 0 Then dbtype!(3, 0) = 0 dbtype!(5, 0) = 0 End If End If ElseIf InStr("C-2C-6C-8C-9", PrimeType$) <> 0 Then SecondShear = True dbtype!(1, 0) = 1 dbtype!(15, 0) = 1 Else dbtype!(1, 0) = 1 End If If (InStr(TypeDeburr$, "OUTSIDE") <> 0) Or (InStr(TypeDeburr$, "NONE") <> 0) Then For outsid = 1 To 16 ' if the operator said OUTSIDE or NONE then none of the options are If outsid <> 14 Then ' valid except the shear only option #14 dbtype!(outsid, 0) = 0 'it could be sheared End If Next End If End If ' ' ' Exclude all parts timesaver deburrs, if necessary. ' ' If Mt$ = "NO TIMESAVER" Then dbtype!(2, 0) = 0 dbtype!(7, 0) = 0 dbtype!(10, 0) = 0 dbtype!(15, 0) = 0 dbtype!(16, 0) = 0 End If ' ' ' Exclude invalid trim cuts for shear operations. ' ' If (InStr(MachinesWithShears$, PrimeType$) <> 0) And (Multi$ = "MULTIPLE") Then If TOP_TRIM_CUT! <> 0 Then If (TOP_TRIM_CUT! <> Bottom_Trim_Cut!) Or ((TOP_TRIM_CUT! <> 2) And (TOP_TRIM_CUT! <> 2.25)) Then For i = 2 To 14 dbtype!(i, 0) = 0 Next dbtype!(16, 0) = 0 End If Else If ((Bottom_Trim_Cut! <> 2) And (Bottom_Trim_Cut! <> 2.25)) Then For i = 2 To 14 dbtype!(i, 0) = 0 Next dbtype!(16, 0) = 0 End If End If End If Celltype$ = UCase$(currform![CellDeburrTypes]) ' ' ' Exclude operations that manual selection has indicated ' ' Select Case Celltype$ Case "HAND DEBURR" dbtype!(2, 0) = 0 dbtype!(5, 0) = 0 dbtype!(6, 0) = 0 dbtype!(7, 0) = 0 dbtype!(9, 0) = 0 dbtype!(10, 0) = 0 dbtype!(12, 0) = 0 dbtype!(15, 0) = 0 dbtype!(16, 0) = 0 Case "PEDESTAL" dbtype!(1, 0) = 0 dbtype!(2, 0) = 0 dbtype!(3, 0) = 0 dbtype!(4, 0) = 0 dbtype!(5, 0) = 0 dbtype!(6, 0) = 0 dbtype!(7, 0) = 0 dbtype!(8, 0) = 0 dbtype!(10, 0) = 0 dbtype!(11, 0) = 0 dbtype!(13, 0) = 0 dbtype!(15, 0) = 0 dbtype!(16, 0) = 0 Case "TIME SAVER" dbtype!(1, 0) = 0 dbtype!(3, 0) = 0 dbtype!(4, 0) = 0 dbtype!(5, 0) = 0 dbtype!(6, 0) = 0 dbtype!(7, 0) = 0 dbtype!(8, 0) = 0 dbtype!(9, 0) = 0 dbtype!(11, 0) = 0 dbtype!(12, 0) = 0 dbtype!(13, 0) = 0 Case Else End Select Call Det_Deburr_Run_Times(CNCTime!, DbSel%, completedeburr%) ' SecondShear = True ' If (TOP_TRIM_CUT! = 0 Or TOP_TRIM_CUT! = 2 Or TOP_TRIM_CUT! = 2.25) And (Bottom_TRIM_CUT! = 2 Or Bottom_TRIM_CUT! = 2.25) Then ' SecondShear = False ' End If 'If ((DbSel% > 2) And (DbSel% < 11)) Or (DbSel% = 13) Or (DbSel% = 14) Or (DbSel% = 16) Then Call CNC_Verbage(DbSel%, vb$) Return End Sub Sub NewGrain() If currform!GrDirOpt = 1 Then currform!GrainDir = "Along First Dimension" End If If currform!GrDirOpt = 2 Then currform!GrainDir = "Along Second Dimension" End If If currform!GrDirOpt = 3 Then currform!GrainDir = "No Grain Direction" End If End Sub Sub OpenMainFiles() 'AddnlQ1 ' currform!txtCalcStat.visible = True ' currform!txtCalcStat.caption = "Open - Opening StAddnlQDB": DoEvents ' Set StAddnlQDB = DBEngine.Workspaces(0).Databases(0) ' Set StAddnlQSet = StAddnlQDB.OpenRecordset("AddnlQ1", DB_OPEN_DynaSet) 'AddnlQ2 ' currform!txtCalcStat.caption = "Open - Opening StAddnlQDB2": DoEvents ' Set StAddnlQDB2 = StAddnlQDB ' Set StAddnlQSet2 = StAddnlQSet ' 'AddnlPROC ' currform!txtCalcStat.caption = "Open - Opening StAddnlDB": DoEvents ' Set StAddnlDB = DBEngine.Workspaces(0).Databases(0) ' Set StAddnlSet = StAddnlQDB.OpenRecordset("AddnlPROC", DB_OPEN_Table) ' 'MachineNames ' currform!txtCalcStat.caption = "Open - Opening StMachNamesDB": DoEvents ' Set StMachNamesDB = DBEngine.Workspaces(0).Databases(0) ' Set StMachNamesSet = StMachNamesDB.OpenRecordset("MachineNames", DB_OPEN_Table) ' 'Machines ' currform!txtCalcStat.caption = "Open - Opening StMachQDB": DoEvents ' Set StMachQDB = DBEngine.Workspaces(0).Databases(0) ' Set StMachQSet = StMachQDB.OpenRecordset("Machines", DB_OPEN_Table) ' 'MachinesQ2 ' currform!txtCalcStat.caption = "Open - Opening StMachQ2DB": DoEvents ' Set StMachQ2DB = DBEngine.Workspaces(0).Databases(0) ' Set StMachQ2Set = StMachQ2DB.OpenRecordset("Machines", DB_OPEN_DynaSet) ' ''Process ' currform!txtCalcStat.caption = "Open - Opening StMainDB": DoEvents ' Set StMainDB = DBEngine.Workspaces(0).Databases(0) ' Set StMainSet = StMainDB.OpenRecordset("Process", DB_OPEN_Table) ' ''Process2 ' currform!txtCalcStat.caption = "Open - Opening StMain2DB": DoEvents ' Set StMain2DB = StMainDB ' Set StMain2Set = StMainSet ' ''PressTab ' currform!txtCalcStat.caption = "Open - Opening StPressTab": DoEvents ' Set StPressTab = DBEngine.Workspaces(0).Databases(0) ' Set StPressTabSet = StPressTab.OpenRecordset("PressBrakes", DB_OPEN_Table) ' ''DataSheet ' currform!txtCalcStat.caption = "Open - Opening StDataShDB": DoEvents ' Set StDataShDB = DBEngine.Workspaces(0).Databases(0) ' Set StDataShSet = StDataShDB.OpenRecordset("DataSheetQ1", DB_OPEN_DynaSet) ' ''PressBrake ' currform!txtCalcStat.caption = "Open - Opening StPressBrk": DoEvents ' Set StPressBrk = DBEngine.Workspaces(0).Databases(0) ' Set StPressBrkSet = StPressBrk.OpenRecordset("PressBrakeQ1", DB_OPEN_DynaSet) ' ''PunchPress ' currform!txtCalcStat.caption = "Open - Opening StPunchPress": DoEvents ' Set StPunchPress = DBEngine.Workspaces(0).Databases(0) ' Set StPunchPressSet = StPunchPress.OpenRecordset("PunchPress", DB_OPEN_Table) ' '''PressBrakeOps ' currform!txtCalcStat.caption = "Open - Opening StPressOps": DoEvents ' Set StPressOps = DBEngine.Workspaces(0).Databases(0) ' Set StPressOpsSet = StPressOps.OpenRecordset("PressBrakeOps", DB_OPEN_Table) ' ' currform!txtCalcStat.visible = False ' End Sub Function Opps$(OpCode%) Opps$ = Right$(" " + Str$(OpCode%), 4) End Function Sub PBFormView() PartN$ = currform![PartNumber] Set MachQDB = DBEngine.Workspaces(0).Databases(0) Set MachQSet = MachQDB.OpenRecordset("MachinesQ1", DB_OPEN_DYNASET) ' Create dynaset. Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set search criteria. PMachine$ = "" MachQSet.FindFirst Criteria$ ' Find first occurrence. FL$ = Trim$(UCase$(itsaNull(currform!PressBrake))) currform!txtPrime = "" PMachine$ = "" Do Until MachQSet.NoMatch ' Loop until no matching records. If MachQSet!Prime = True Then PMachine$ = MachQSet!MachineName Exit Do End If MachQSet.FindNext Criteria$ ' Find next occurrence. DoEvents Loop currform!txtPrime = PMachine$ currform!PressBrake.Requery Select Case FL$ Case "1" currform!PressBrakeSubForm.Visible = False Case Else currform!PressBrakeSubForm.Visible = True End Select End Sub Sub PemPressView() FL$ = Trim$(UCase$(currform!Pems)) Select Case FL$ Case "-1" currform![PemPress Ops subform].Visible = True currform![lblPemBefore].Visible = True currform![PemBefore].Visible = True Case Else currform![PemPress Ops subform].Visible = False currform![lblPemBefore].Visible = False currform![PemBefore].Visible = False End Select End Sub Sub PunchPressOptions() If IsNull(currform!PunchDie) Then currform!PunchDie = "!NONE!" If Trim$(currform!PunchDie) = "" Then currform!PunchDie = "!NONE!" If (currform!CutType = "Multiple") Or (currform!CutType = "Laser") Or (currform!CutType = "Salvagnini") Or (currform!CutType = "Laser/Shear") Or (currform!CutType = "Slug") Then currform!PunchPressOption.Visible = False currform!PunchDie.Visible = False currform!PunchCount.Visible = False currform!PunchStd.Visible = False Else currform!PunchDie.Visible = True If (currform!CutType = "Single") Then currform!PunchOpt1.Caption = "Before CNC" currform!PunchOpt2.Caption = "After CNC" currform!PunchCount.Visible = False currform!PunchStd.Visible = True Else currform!PunchOpt1.Caption = "Single" currform!PunchOpt2.Caption = "Strip" If currform!PunchPressOption = 2 Then currform!PunchCount.Visible = True currform!PunchStd.Visible = True Else currform!PunchCount.Visible = True currform!PunchStd.Visible = True End If End If If currform!PunchDie = "!NONE!" Then currform!PunchPressOption.Visible = False currform!PunchCount.Visible = False currform!PunchStd.Visible = False Else currform!PunchPressOption.Visible = True End If End If If IsNull(currform!PunchPressOption) Then currform!PunchPressOption = 1 If currform!PunchPressOption = 0 Then currform!PunchPressOption = 1 If currform!PunchDie = "!NONE!" Then currform!PunchPressOption = 1 End Sub Sub PurgeCNCs() If Not OutPutData% Then Exit Sub End If Dim MainDB As Database, MainSet As Recordset Dim MachNamesDB As Database, MachNamesSet As Recordset Dim MachQDB As Database, MachQSet As Recordset Set MainDB = DBEngine.Workspaces(0).Databases(0) Set MachNamesDB = DBEngine.Workspaces(0).Databases(0) Set MachQDB = DBEngine.Workspaces(0).Databases(0) Set MachNamesSet = MachNamesDB.OpenRecordset("MachineNames", DB_OPEN_TABLE) ' Create dynaset. Set MachQSet = MachQDB.OpenRecordset("Machines", DB_OPEN_TABLE) ' Create dynaset. Set MainSet = MainDB.OpenRecordset("Process", DB_OPEN_TABLE) ' Create dynaset. PartN$ = currform![PartNumber] MainSet.Index = "PrimaryKey" MachQSet.MoveFirst MachQSet.Index = "PartNumber" MachQSet.Seek ">=", PartN$ If Not (MachQSet.NoMatch) Then Do While Trim$(MachQSet!PartNumber) = PartN$ A$ = MachQSet!Tool If (A$ = "***") Then MachQSet.Delete End If MachQSet.MoveNext If (MachQSet.EOF) Then Exit Do Loop End If currform.Refresh End Sub Public Function ShearsName() As String shearsdotpath$ = "C:\Files\Shears.pth" If Not Exists(shearsdotpath) Then shearsdotpath = "C:\Shears.pth" If Not Exists(shearsdotpath) Then shearsdotpath = "" End If End If ShearsName = shearsdotpath End Function Function ReadInits() On Error GoTo ErrorRead Open ShearsName For Input As #1 Line Input #1, i$: Sheet1path$ = Trim$(i$) Line Input #1, i$: Sheet2path$ = Trim$(i$) Line Input #1, i$: Initforms$ = Trim$(i$) Line Input #1, i$: Directory$ = Trim$(i$) Line Input #1, i$: usrID$ = Trim$(i$) Close #1 If Right$(Directory, 1) <> "\" Then Directory$ = Directory$ + "\" End If If Left$(Initforms$, 2) = "14" Then DocName$ = "14" + Chr$(34) + " Process Sheet" Else DocName$ = "Process Sheet" End If PrimaryScreen$ = DocName$ 'Put the configuation inside the database Leaving the As400 User in the Shears.Pth file. 1/11/2019 SG Set dbConfTableWA = DBEngine.Workspaces(0).Databases(0) Set rsConfTablewa = dbConfTableWA.OpenRecordset("ConfigurationTable") rsConfTablewa.MoveFirst Do While Not (rsConfTablewa.EOF) If rsConfTablewa!VarName = "Sheet1Path" Then Sheet1path$ = rsConfTablewa!VarValue If rsConfTablewa!VarName = "Sheet2Path" Then Sheet2path$ = rsConfTablewa!VarValue If rsConfTablewa!VarName = "Directory" Then Directory$ = rsConfTablewa!VarValue rsConfTablewa.MoveNext Loop Exit Function ErrorRead: i$ = "" Resume Next End Function Sub RefreshFromPhantom(NewPart$, Oldpart$) ' NewPart$ = Make Part ' OldPart$ = Phantom Part ' ' to refresh from a Phantom the folllowing steps must occur. ' ' 1) Delete all Generated records from the Make part. ' ' 2) copy in all records from the Phantom and mark them as Generated ' ' ' ' ' ' Dim MainDB As Database, MainSet As Recordset Dim Main2DB As Database, Main2Set As Recordset Dim MachNamesDB As Database, MachNamesSet As Recordset Dim MachQDB As Database, MachQSet As Recordset Dim AddnlQDB As Database, AddnlQSet As Recordset Dim MainTableDef As TableDef Set MainDB = DBEngine.Workspaces(0).Databases(0) Set Main2DB = DBEngine.Workspaces(0).Databases(0) Set MachNamesDB = DBEngine.Workspaces(0).Databases(0) Set MachQDB = DBEngine.Workspaces(0).Databases(0) Set AddnlQDB = DBEngine.Workspaces(0).Databases(0) Set AddnlQSet = AddnlQDB.OpenRecordset("AddnlProc", DB_OPEN_DYNASET) ErrM$ = " " GoSub XOpen_Mains Set MachNamesSet = MachNamesDB.OpenRecordset("MachineNames", DB_OPEN_TABLE) Set MachQSet = MachQDB.OpenRecordset("Machines", DB_OPEN_TABLE) ' Set MachNamesSet = StMachNamesSet ' Set MachQSet = StMachQSet If (Trim$(Oldpart$) <> "") And (Trim$(NewPart$) <> "") Then PartN$ = NewPart$ If PartN$ <> "" Then If Oldpart$ <> PartN$ Then Main2Set.Seek "=", PartN$ MainSet.Seek "=", Oldpart$ Main2Set.Edit For i = 0 To MainSet.Fields.Count - 1 fld$ = MainSet.Fields(i).name If (fld$ <> "PartNo") And (fld$ <> "PartNumber") And (fld$ <> "Phantom") Then Main2Set.Fields(i) = MainSet.Fields(i) End If Next i Main2Set.Update GoSub XOPEN_Addnl MainSet.MoveFirst MainSet.Seek ">=", PartN$ If Not (MainSet.NoMatch) Then Do While Trim$(MainSet!PartNumber) = PartN$ g% = MainSet!Generated ' Get Generation flag. If g% = True Then ' if this is a generated record the delete it MainSet.Delete End If MainSet.MoveNext If (MainSet.EOF) Then Exit Do Loop End If MainSet.MoveFirst MainSet.Seek ">=", Oldpart$ If Not (MainSet.NoMatch) Then Do While Trim$(MainSet!PartNumber) = Oldpart$ Main2Set.AddNew For i = 0 To MainSet.Fields.Count - 1 If MainSet.Fields(i).name = "PartNo" Then Main2Set.Fields(i) = Oldpart$ Else Main2Set.Fields(i) = MainSet.Fields(i) End If If MainSet.Fields(i).name = "Generated" Then Main2Set.Fields(i) = True End If Next i Main2Set!PartNumber = PartN$ Main2Set.Update MainSet.MoveNext If MainSet.EOF Then Exit Do Loop End If GoSub XOPEN_Machs MainSet.MoveFirst MainSet.Seek ">=", Oldpart$ If Not (MainSet.NoMatch) Then Do While Trim$(MainSet!PartNumber) = Oldpart$ Main2Set.AddNew For i = 0 To MainSet.Fields.Count - 1 If MainSet.Fields(i).name = "PartNo" Then Main2Set.Fields(i) = Oldpart$ Else Main2Set.Fields(i) = MainSet.Fields(i) End If Next i Main2Set!PartNumber = PartN$ Main2Set.Update MainSet.MoveNext If MainSet.EOF Then Exit Do Loop End If GoSub XOPEN_Press MainSet.MoveFirst MainSet.Seek ">=", Oldpart$ If Not (MainSet.NoMatch) Then Do While Trim$(MainSet!PartNumber) = Oldpart$ Main2Set.AddNew For i = 0 To MainSet.Fields.Count - 1 If MainSet.Fields(i).name = "PartNo" Then Main2Set.Fields(i) = Oldpart$ Else Main2Set.Fields(i) = MainSet.Fields(i) End If Next i Main2Set!PartNumber = PartN$ Main2Set.Update MainSet.MoveNext If MainSet.EOF Then Exit Do Loop End If GoSub XOpen_Mains End If End If End If ErrM$ = "Part " + PartN$ + " added" Exit Sub XOpen_Mains: Set MainSet = MainDB.OpenRecordset("Process", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("Process", DB_OPEN_TABLE) ' Create dynaset. ' Set mainset = StMainSet ' Set main2Set = StMainSet MainSet.Index = "PrimaryKey" Main2Set.Index = "PrimaryKey" Return XOPEN_Addnl: Set MainSet = MainDB.OpenRecordset("AddnlProc", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("AddnlProc", DB_OPEN_TABLE) ' Create dynaset. ' Set mainset = StAddnlSet ' Set main2Set = StAddnlSet MainSet.Index = "PartNumber" Main2Set.Index = "PartNumber" Return XOPEN_Machs: Set MainSet = MainDB.OpenRecordset("Machines", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("Machines", DB_OPEN_TABLE) ' Create dynaset. ' Set mainset = StMachQSet ' Set main2Set = StMachQSet MainSet.Index = "PartNumber" Main2Set.Index = "PartNumber" ''' Refresh Return XOPEN_Press: Set MainSet = MainDB.OpenRecordset("PressBrakeOPs", DB_OPEN_TABLE) ' Create dynaset. Set Main2Set = Main2DB.OpenRecordset("PressBrakeOPs", DB_OPEN_TABLE) ' Create dynaset. ' Set mainset = StPressOpsSet ' Set main2Set = StPressOpsSet MainSet.Index = "PartNumber" Main2Set.Index = "PartNumber" ''''CurrForm.Refresh Return Purge_GeneratedRecords: AddnlQSet.FindFirst Criteria$ ' Find first occurrence. Do Until AddnlQSet.NoMatch ' Loop until no matching records. Generated% = AddnlQSet!Generated ' Get Generation flag. s$ = AddnlQSet!PartNumber If Generated% = True Then ' if this is a generated record the delete it AddnlQSet.Delete ' Delete it. End If AddnlQSet.FindNext Criteria$ ' Find next occurrence. Loop ' End of loop. Return XDUPLICATE_rec: ErrM$ = "Duplicate record - " + PartN$ ef = 1 Resume Next End Sub Sub renumber() Dim AddnlQDB As Database, AddnlQSet As Recordset Dim AddnlDB As Database, AddnlSet As Recordset Dim MachQDB As Database, MachQSet As Recordset Dim AddnlQDB2 As Database, AddnlQSet2 As Recordset, Hopc! Static insertOp%(50) ' Set AddnlDB = DBEngine.Workspaces(0).Databases(0) ' Set AddnlSet = AddnlQDB.OpenRecordset("AddnlPROC", DB_OPEN_Table) ' Create dynaset. InsertOpNo% = 0 PartN$ = currform![PartNumber] currform!txtCalcStat.Caption = "Renumbering process sheet" DoEvents Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set search criteria. Cr$ = Criteria$ currform!txtCalcStat.Caption = "RN - Opening AddnlQ1" DoEvents Set AddnlQDB = DBEngine.Workspaces(0).Databases(0) Set AddnlQSet = AddnlQDB.OpenRecordset("AddnlQ1", DB_OPEN_DYNASET) ' Create dynaset. currform!txtCalcStat.Caption = "RN - Opening AddnlQ1 again" DoEvents Set AddnlQSet2 = AddnlQDB.OpenRecordset("AddnlQ1", DB_OPEN_DYNASET) ' Create dynaset. currform!txtCalcStat.Caption = "RN - Opening AddnlPROC" DoEvents Set AddnlDB = DBEngine.Workspaces(0).Databases(0) Set AddnlSet = AddnlQDB.OpenRecordset("AddnlPROC", DB_OPEN_TABLE) AddnlQSet.FindFirst Criteria$ ' Find first occurrence. Hopc = 0 currform!txtCalcStat.Caption = "Renumbering process sheet" DoEvents Do Until AddnlQSet.NoMatch ' Loop until no matching records. Generated% = AddnlQSet!Generated ' Get Generation flag. s$ = AddnlQSet!PartNumber If Generated% = True Then ' if this is a generated record the delete it If Val(AddnlQSet!OpCode) > Hopc Then Hopc = AddnlQSet!OpCode End If End If AddnlQSet.FindNext Criteria$ ' Find next occurrence. DoEvents Loop ' End of loop. AddnlQSet.FindFirst Criteria$ ' Find first occurrence. Hopc = (Hopc \ 10) * 10 Do Until AddnlQSet.NoMatch ' Loop until no matching records. Generated% = AddnlQSet!Generated ' Get Generation flag. If Not (Generated%) Then tp$ = Left$(LTrim$(AddnlQSet!OpCode), 1) Select Case tp$ Case "*", "$" t$ = Trim$(Mid$(AddnlQSet!OpCode, 2)) dd$ = AddnlQSet!Description C$ = "" 'Do ' If InStr(dd$, "~") <> 0 Then ' DIX = InStr(dd$, "~") ' e$ = Rpadd$(Left$(dd$, DIX - 1), Descrw) ' c$ = c$ + e$ ' dd$ = Mid$(d$, DIX + 1) ' Else ' Exit Do ' End If 'Loop 'd$ = c$ + Rpad$(d$, Descrw) Call AddDescr(C$, dd$, DescrW) dd$ = C$ If Not (IsNull(AddnlQSet!CycleTime)) Then Rstd! = AddnlQSet!CycleTime If Rstd! = 0 Then Rstd! = 1 Else Rstd! = 1 End If AddnlQSet2.FindFirst Criteria$ Do Until AddnlQSet2.NoMatch ' Loop until no matching records. If Trim$(AddnlQSet2!OpCode) = t$ Then AddnlQSet2.Edit e$ = AddnlQSet2!Description If tp$ = "$" Then dd$ = dd$ + e$ Else dd$ = e$ + dd$ End If AddnlQSet2!Description = dd$ Rstd! = Rstd! * AddnlQSet2!RunStd AddnlQSet2!RunStd = Rstd! AddnlQSet2.Update End If AddnlQSet2.FindNext Criteria$ ' Find next occurrence. Loop ' End of loop. Case "!", "@" opc$ = lpad$(Mid$(AddnlQSet!OpCode, 2), 4) If tp$ = "@" Then InsertOpNo% = InsertOpNo% + 1 insertOp%(InsertOpNo%) = Val(Trim$(opc$)) End If opc$ = lpad$(Mid$(AddnlQSet!OpCode, 2) + tp$, 4) PartN$ = AddnlQSet!PartNumber DESCR$ = AddnlQSet!Description wc1$ = itsaNull$(AddnlQSet!wc1) wc2$ = itsaNull$(AddnlQSet!wc2) wc3$ = itsaNull$(AddnlQSet!wc3) wc4$ = itsaNull$(AddnlQSet!wc4) Machine$ = itsaNull$(AddnlQSet!Machine) ctime! = AddnlQSet!CycleTime Rstd! = AddnlQSet!RunStd AddnlQSet.AddNew AddnlQSet!PartNumber = PartN$ AddnlQSet!OpCode = opc$ AddnlQSet!Generated = True AddnlQSet!Description = DESCR$ AddnlQSet!wc1 = lpad$(wc1$, 3) AddnlQSet!wc2 = lpad$(wc2$, 3) AddnlQSet!wc3 = lpad$(wc3$, 3) AddnlQSet!wc4 = lpad$(wc4$, 3) AddnlQSet!Machine = rpad$(Machine$, 30) AddnlQSet!CycleTime = ctime! AddnlQSet!RunStd = Rstd! AddnlQSet.Update Case Else Hopc = Hopc + 10 AddnlQSet.Edit AddnlQSet!OpCode = lpad$(Str$(Hopc), 4) AddnlQSet.Update End Select End If AddnlQSet.FindNext Criteria$ ' Find next occurrence. DoEvents Loop ' End of loop. 'Exit Sub cnt = 0 If InsertOpNo% > 0 Then For imv = 1 To InsertOpNo% GreaterThan% = insertOp%(imv) AddnlQSet.FindFirst Criteria$ ' Find first occurrence. Do Until AddnlQSet.NoMatch ' Loop until no matching records. Generated% = AddnlQSet!Generated ' Get Generation flag. s$ = AddnlQSet!PartNumber If Generated% = True Then ' if this is a generated record the delete it HopS$ = AddnlQSet!OpCode HopS$ = Trim$(HopS$) lc$ = Right$(HopS$, 1) atsign$ = lc$ vop% = Val(HopS$) If (vop% >= GreaterThan%) And ((lc$ <> "@") And (lc$ <> "!")) Then vop% = vop% + 10 HopI$ = Trim$(Str$(vop%)) ' + lc$ AddnlQSet.Edit AddnlQSet!OpCode = lpad$(HopI$, 4) AddnlQSet.Update End If End If AddnlQSet.FindNext Criteria$ ' Find next occurrence. Loop Next End If AddnlQSet.FindFirst Criteria$ ' Find first occurrence. Hopc = 0 Do Until AddnlQSet.NoMatch ' Loop until no matching records. Generated% = AddnlQSet!Generated ' Get Generation flag. s$ = AddnlQSet!PartNumber If Generated% = True Then ' if this is a generated record the delete it HopS$ = Trim$(AddnlQSet!OpCode) lc$ = Right$(HopS$, 1) If lc$ = "!" Or lc$ = "@" Then HopI$ = Left$(HopS$, Len(HopS$) - 1) AddnlQSet.Edit AddnlQSet!OpCode = lpad$(HopI$, 4) AddnlQSet.Update End If End If AddnlQSet.FindNext Criteria$ ' Find next occurrence. Loop ' End of loop. currform!txtCalcStat.Caption = "Renumbering process sheet - done" DoEvents End Sub Function revpart$(FL$) ' 'This routine converts the partnumber xxxxxxxR to ' xxxxxxx.R use a "-" to make a " " fx = Len(FL$) Rev$ = Right$(FL$, 1) If (fx = 8) And (InStr("0123456789", Rev$) <> 0) Then Else If (Rev$ = "-") Or (InStr("0123456789", Rev$) <> 0) Then Rev$ = "" End If End If revpart$ = "\" + Left$(FL$, fx - 1) + "." + Rev$ End Function Function rpad$(A$, l) rpad$ = Left$(A$ + Space$(l), l) End Function Sub Shear1FILE() TRIMSHEETLEN! = Sheet_Length! - Trim_Cut! If ExtraShear% Then Shear1OffAll = TRIMSHEETLEN! - SecondCut! * Blocks_Per_Sheet Else Shear1OffAll = TRIMSHEETLEN! - FirstCut! * Blocks_Per_Sheet End If Open ShearsName For Input As #1 Line Input #1, Sheet1path$ Line Input #1, Sheet2path$ Close #1 Sheet1path$ = Trim$(Sheet1path$) Sheet2path$ = Trim$(Sheet2path$) FL$ = Trim$(currform!PartNumber) FL$ = revpart$(FL$) Open Sheet1path$ + FL$ For Output As #1 Print #1, Format$(TRIMSHEETLEN!, "##0.000") Print #1, "A3" If ExtraShear% Then Print #1, Format$(SecondCut!, "##0.000") Else Print #1, Format$(FirstCut!, "##0.000") End If If Shear1OffAll >= 2 Then Print #1, Format$(currform!BlocksPerSheet, "###0") Else If currform!BlocksPerSheet > 1 Then NumBlocks = currform!BlocksPerSheet - 1 Print #1, Format$(NumBlocks, "##0") If ExtraShear% Then Print #1, Format$(SecondCut!, "##0.000") Else Print #1, Format$(FirstCut!, "##0.000") End If End If Print #1, "A2" End If Print #1, "0" Print #1, "00" Print #1, "(NAME : "; currform![PartName] Print #1, "PARTS/SHEET : ["; FormitS$(parts_per_sheet!, "###"); "]" If (Multi$ = "MULTIPLE") Or (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then If ExtraShear% Then If InStr(Prime$, "LASER") = 0 Then Print #1, "CNC : ["; FormitS$(Parts_Per_blank, "###"); "] PARTS PER BLANK" Print #1, "#2 SHEAR CUT : ["; FormitS$(Blanks_Per_Block, "###"); "] "; FormitS$(FirstCut, "###.000"); " X "; FormitS$(SecondCut, "###.000") Else Print #1, "LASER : ["; FormitS$(Parts_Per_blank, "###"); "] PARTS PER BLANK" Print #1, "LASER CUT : ["; FormitS$(Blanks_Per_Block!, "###"); "] "; FormitS$(FirstCut, "###.000"); " X "; FormitS$(SecondCut, "###.000") End If Else If InStr(Prime$, "LASER") = 0 Then Print #1, "#2 SHEAR CUT : ["; FormitS$(Parts_Per_blank!, "###"); "] "; FormitS$(SecondCut, "###.000"); " X "; FormitS$(FirstCut, "###.000") Else Print #1, "LASER CUT : ["; FormitS$(Parts_Per_blank!, "###"); "] "; FormitS$(SecondCut, "###.000"); " X "; FormitS$(FirstCut, "###.000") End If End If Else Print #1, "#2 SHEAR CUT : ["; FormitS$(Blanks_Per_Block!, "###"); "] "; FormitS$(SecondCut, "###.000"); " X "; FormitS$(FirstCut, "###.000") End If If ExtraShear% Then Print #1, "#1 SHEAR CUT : ["; FormitS$(Blocks_Per_Sheet!, "###"); "] "; FormitS$(SecondCut, "###.000"); " X "; FormitS$(Sheet_Width!, "###.000") Else Print #1, "#1 SHEAR CUT : ["; FormitS$(Blocks_Per_Sheet!, "###"); "] "; FormitS$(FirstCut, "###.000"); " X "; FormitS$(Sheet_Width!, "###.000") End If Print #1, "SHEET SIZE : "; LTrim$(FormitS$(Sheet_Width, "###.00") + " X " + FormitS$(Sheet_Length, "###.00")) Print #1, "MATERIAL : "; Left$(Gauge$, 2); " Ga. "; Select Case Left$(MetalName$, 3) Case "S/S" Print #1, "S/S "; Case "Col" Print #1, "C/R "; Case "Alu" Print #1, "ALZ "; Case "Gal" Print #1, "GAL "; Case Else End Select Print #1, MetalPart$ Print #1, "REVISION : "; Right$(currform![PartNumber], 1) Print #1, "PARTNUMBER : "; currform![PartNumber] Print #1, "** 1st CUT SHEAR #1 FILE **)" Close #1 End Sub Sub Shear2FILE() TRIMSHEETWdth! = Sheet_Width! - Trim_Cut! Open ShearsName For Input As #1 Line Input #1, Sheet1path$ Line Input #1, Sheet2path$ Close #1 Sheet1path$ = Trim$(Sheet1path$) Sheet2path$ = Trim$(Sheet2path$) FL$ = Trim$(currform!PartNumber) fx = Len(FL$) Rev$ = Right$(FL$, 1) If (Rev$ = "-") Or (InStr("0123456789", Rev$) <> 0) Then Rev$ = "" End If FL$ = "\" + Left$(FL$, fx - 1) + "." + Rev$ Open Sheet2path$ + FL$ For Output As #1 If Multi$ <> "MULTIPLE" Or ExtraShear% Then Print #1, Format$(TRIMSHEETWdth!, "###0.000") Print #1, "A3" If ExtraShear% Then Shear2OffAll = TRIMSHEETWdth! - FirstCut! * currform!BlanksPerBlock Print #1, Format$(FirstCut, "###0.000") Else Shear2OffAll = TRIMSHEETWdth! - SecondCut! * currform!BlanksPerBlock Print #1, Format$(SecondCut, "###0.000") End If If Shear2OffAll >= 2 Then Print #1, Format$(currform!BlanksPerBlock, "###0.000") Else If currform!BlanksPerBlock > 1 Then NumBlanks = currform!BlanksPerBlock - 1 Print #1, Format$(NumBlanks, "##0") If ExtraShear% Then Print #1, Format$(FirstCut!, "##0.000") Else Print #1, Format$(SecondCut!, "##0.000") End If End If Print #1, "A2" End If Print #1, "0" Print #1, "A0" Else If (Bottom_Trim_Cut! >= 2) Or (currform![ActualPartHeight] >= 2) Then FIRSTCUTLESSTOP = FirstCut - TOP_TRIM_CUT! FIRSTCUTLESSBOTTOM = FirstCut - Bottom_Trim_Cut! If TOP_TRIM_CUT <= 0 Then If Bottom_Trim_Cut >= 2 Then Print #1, Format$(Bottom_Trim_Cut, "##0.000") Else Print #1, Format$(FIRSTCUTLESSBOTTOM, "##0.000") End If Print #1, "A2" Print #1, "0" Print #1, "A0" Else Print #1, Format$(FIRSTCUTLESSTOP, "##0.000") Print #1, "A2" Print #1, Format$(currform![ActualPartHeight], "##0.000") If Bottom_Trim_Cut >= 2 Then Print #1, "1" Else Print #1, "A2" End If Print #1, "0" Print #1, "A0" End If End If End If Print #1, "(NAME : "; currform![PartName] Print #1, "PARTS/SHEET : ["; FormitS$(parts_per_sheet!, "###"); "]" If (Multi$ = "MULTIPLE") Or (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then If ExtraShear% Then If InStr(Prime$, "LASER") = 0 Then Print #1, "CNC : ["; FormitS$(Parts_Per_blank, "###"); "] PARTS PER BLANK" Print #1, "#2 SHEAR CUT : ["; FormitS$(Blanks_Per_Block, "###"); "] "; FormitS$(FirstCut, "###.000"); " X "; FormitS$(SecondCut, "###.000") Else Print #1, "LASER : ["; FormitS$(Parts_Per_blank, "###"); "] PARTS PER BLANK" Print #1, "LASER CUT : ["; FormitS$(Blanks_Per_Block!, "###"); "] "; FormitS$(FirstCut, "###.000"); " X "; FormitS$(SecondCut, "###.000") End If Else If InStr(Prime$, "LASER") = 0 Then Print #1, "#2 SHEAR CUT : ["; FormitS$(Parts_Per_blank!, "###"); "] "; FormitS$(SecondCut, "###.000"); " X "; FormitS$(FirstCut, "###.000") Else Print #1, "LASER CUT : ["; FormitS$(Parts_Per_blank!, "###"); "] "; FormitS$(SecondCut, "###.000"); " X "; FormitS$(FirstCut, "###.000") End If End If Else Print #1, "#2 SHEAR CUT : ["; FormitS$(Blanks_Per_Block!, "###"); "] "; FormitS$(SecondCut, "###.000"); " X "; FormitS$(FirstCut, "###.000") End If If ExtraShear% Then Print #1, "#1 SHEAR CUT : ["; FormitS$(Blocks_Per_Sheet!, "###"); "] "; FormitS$(SecondCut, "###.000"); " X "; FormitS$(Sheet_Width!, "###.000") Else Print #1, "#1 SHEAR CUT : ["; FormitS$(Blocks_Per_Sheet!, "###"); "] "; FormitS$(FirstCut, "###.000"); " X "; FormitS$(Sheet_Width!, "###.000") End If Print #1, "SHEET SIZE : "; LTrim$(FormitS$(Sheet_Width, "###.00") + " X " + FormitS$(Sheet_Length, "###.00")) Print #1, "MATERIAL : "; Left$(Gauge$, 2); " Ga. "; Select Case Left$(MetalName$, 3) Case "S/S" Print #1, "S/S "; Case "Col" Print #1, "C/R "; Case "Alu" Print #1, "ALZ "; Case "Gal" Print #1, "GAL "; Case Else End Select Print #1, MetalPart$ Print #1, "REVISION : "; Right$(currform![PartNumber], 1) Print #1, "PARTNUMBER : "; currform![PartNumber] Print #1, "** 2nd CUT SHEAR FILE **)" Close #1 Exit Sub Print #1, "(NAME : "; currform![PartName] Print #1, "PARTS/SHEET : ["; FormitS$(parts_per_sheet!, "###"); "]" If Multi$ = "MULTIPLE" Then If InStr(Prime$, "LASER") = 0 Then Print #1, "#2 SHEAR CUT : ["; FormitS$(Parts_Per_blank!, "###"); "] "; FormitS$(SecondCut, "###.000"); " X "; FormitS$(FirstCut, "###.000"); "" Else Print #1, "LASER CUT : ["; FormitS$(Parts_Per_blank!, "###"); "] "; FormitS$(SecondCut, "###.000"); " X "; FormitS$(FirstCut, "###.000"); "" End If Else Print #1, "#2 SHEAR CUT : ["; FormitS$(Blanks_Per_Block!, "###"); "] "; FormitS$(SecondCut, "###.000"); " X "; FormitS$(FirstCut, "###.000"); "" End If Print #1, "#1 SHEAR CUT : ["; FormitS$(Blocks_Per_Sheet!, "###"); "] "; FormitS$(FirstCut, "###.000"); " X "; FormitS$(Sheet_Width!, "###.000") Print #1, "SHEET SIZE : "; LTrim$(FormitS$(Sheet_Width, "###.00") + " X " + FormitS$(Sheet_Length, "###.00")) Print #1, "MATERIAL : "; Left$(Gauge$, 2); " Ga. "; Select Case Left$(MetalName$, 3) Case "S/S" Print #1, "S/S "; Case "Col" Print #1, "C/R "; Case "Alu" Print #1, "ALZ "; Case "Gal" Print #1, "GAL "; Case Else End Select Print #1, MetalPart$ Print #1, "REVISION : "; Right$(currform![PartNumber], 1) Print #1, "PARTNUMBER : "; currform![PartNumber] Print #1, "** 2nd CUT SHEAR FILE **)" Close #1 End Sub Sub UtilGrossWt(Sheet_W!, Sheet_L!, lb_per_sq_ft!, Gw!, Aw!, MainSet As Recordset) ' 'answers ' ' PartCost ' ' Sheet_Length! = Sheet_L! Sheet_Width! = Sheet_W! 'Parting tool width = .2 Pt_Width! = 0.2: Trim_Cut = 0.1 acd$ = MainSet![PartNumber] If acd$ = "9108601L" Then acd$ = "" End If GrNone% = MainSet![GrainNone] Grain$ = Trim$(UCase$(MainSet![GrainDir])) ' currform!lblCalcStat.Visible = True ' currform!txtCalcStat.Caption = "Calculations underway" ' currform!txtCalcStat.Visible = True ' currform!txtCalcStat2.Visible = True DoEvents OutPutData% = True Gw! = 0 ' If MainSet![PartNumber] = "9100890F" Then ' Stop ' End If If GrNone% Then GrNone% = False Grain$ = "ALONG FIRST" OutPutData% = False ' currform!txtCalcStat2.Caption = "Calculating along first dimension" DoEvents GoSub UTCalcPart prc1 = Gw! GrNone% = False Grain$ = "ALONG SECOND" OutPutData% = True ' currform!txtCalcStat2.Caption = "Calculating along Second dimension" DoEvents GoSub UTCalcPart prc2 = Gw! Debug.Print prc1, prc2 If prc1 < prc2 Then MainSet!GrainDir = "Along First Dimension" ElseIf prc1 > prc2 Then MainSet!GrainDir = "Along Second Dimension" Else If First_Dim! < Second_dim! Then MainSet!GrainDir = "Along First Dimension" Else MainSet!GrainDir = "Along Second Dimension" End If End If ' Call GrainFromRec If MainSet!GrainDir <> "Along Second Dimension" Then Grain$ = MainSet!GrainDir GrNone% = False OutPutData% = True ' Forms![Utilization]!lblStatus.Caption = "Calculating along chosen dimension" DoEvents GoSub UTCalcPart GrNone% = True End If Else ' Forms![Utilization]!lblStatus.Caption = "Calculating along only dimension" HoldGrD$ = Trim$(MainSet![GrainDir]) GoSub UTCalcPart MainSet![GrainDir] = HoldGrD$ End If MainSet![GrossWt] = MainSet![GrossWt] * MainSet![USAGE] ' * 12 MainSet![ActualWt] = MainSet![ActualWt] * MainSet![USAGE] ' * 12 Gw! = MainSet![GrossWt] Aw! = MainSet![ActualWt] MainSet.Update Exit Sub UTCalcPart: MainSet.Edit MainSet![GrossWt] = 0 MainSet![ActualWt] = 0 MainSet![Utilization] = 0 MainSet![PartsPerSheet] = 0 MainSet![BlocksPerSheet] = 0 MainSet![BlanksPerBlock] = 0 MainSet![ActualPartHeight] = 0 MainSet![ActualPartWidth] = 0 MainSet![SheetSize] = " " MainSet![BlankSize] = " " MainSet![PartSize] = " " NoDataSheets% = 0 MainSet![CalculationStatus] = 0 First_Dim! = ItsAZero!(MainSet![FirstDim]) Second_dim! = ItsAZero!(MainSet![SecDim]) Denting% = 0 Parts_Per_blank! = ItsAZero!(MainSet![PartsPerBlank]) Part_Height! = ItsAZero!(MainSet![PartHeight]) Bottom_Trim_Cut! = ItsAZero!(MainSet![BotTrimCut]) TOP_TRIM_CUT! = ItsAZero!(MainSet![TopTrimCut]) Part_Width! = ItsAZero!(MainSet![PartWidth]) Punch$ = itsaNull$(MainSet![PunchNumber]) PunchDieDescr$ = itsaNull$(MainSet![PunchNumber]) PunchCounter% = Val(itsaNull$(MainSet![PunchPartsPerStrip])) PunchPresserOptions% = Val(itsaNull$(MainSet![PunchOption])) OrigPartW! = ItsAZero(MainSet!OriginalPartW) If PurchaseBlank% Then First_Dim! = Sheet_Length! Second_dim! = Sheet_Width! End If Multi$ = Trim$(UCase$(MainSet![CutType])) TypeDeburr$ = Trim$(UCase$(MainSet![Deburr])) ' If (Multi$ = "MULTIPLE") Or (Multi$ = "LASER")or(Multi$ = "SALVAGNINI") Then ' If InStr(MN$, "S/S") <> 0 Then ' If MainSet!GrainShearChk.Visible Then ExtraShear% = MainSet![GrainShear] ' Else ' ExtraShear% = False ' End If PartN$ = MainSet![PartNumber] If (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then ppb% = Int(Sheet_Width! / (Second_dim! / Parts_Per_blank!)) Second_dim! = Sheet_Width! Parts_Per_blank! = ppb% End If If Multi$ = "MULTIPLE" Then ' ppb% = Int((Second_dim! - Pt_Width!) / (Part_Width! + Pt_Width!)) If ExtraShear% Then If Second_dim! <> Part_Width Then ppb% = Int((Second_dim!) / (Part_Width! + Pt_Width!)) Else ppb% = 1 End If Else Second_dim! = Sheet_Width! ppb% = Int((Second_dim!) / (Part_Width! + Pt_Width!)) End If If (ppb% = 0) And (Parts_Per_blank! = 1) Then ppb% = 1 End If Parts_Per_blank! = ppb% End If If (First_Dim! = 0) Or (Second_dim! = 0) Or (lb_per_sq_ft! = 0) Then RC% = 6: GoSub Setcalcstat MainSet.Update Exit Sub End If If ((Multi$ = "MULTIPLE") Or (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG")) And (Parts_Per_blank! = 0) Then RC% = 6: GoSub Setcalcstat MainSet.Update Exit Sub End If If (Multi$ = "MULTIPLE") And (Part_Width! = 0) Then RC% = 10: GoSub Setcalcstat MainSet.Update Exit Sub End If If (Multi$ = "BLANK") Then If (Second_dim! > Sheet_Width!) Then RC% = 10: GoSub Setcalcstat MainSet.Update Exit Sub End If End If If (Bottom_Trim_Cut! < 2) And (Multi$ = "MULTIPLE") Then RC% = 5: GoSub Setcalcstat MainSet.Update Exit Sub End If If (Multi$ = "NO CNC") And (Punch$ <> "!NONE!") Then If PunchPresserOptions% = 2 Then Second_dim! = Sheet_Width! End If Part_Width! = (OrigPartW! / PunchCounter%) ppb% = (Sheet_Width! / Part_Width!) Parts_Per_blank! = ppb% MainSet![PartsPerBlank] = Parts_Per_blank! ' Blanks_Per_Block! = Int((Sheet_Width - TRIM_CUT) / Second_dim!) ' MainSet![BlanksPerBlock] = Blanks_Per_Block! ' asdc$ = MainSet![PartNumber] End If If (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then Part_Width! = (Sheet_Width! / Parts_Per_blank) - Pt_Width! Bottom_Trim_Cut! = 0 TOP_TRIM_CUT! = 0 End If If Multi$ <> "BLANK" Then Calcerr0% = MainSet![CalculationStatus] GoSub UTCalcMaterialWt calcerr1% = MainSet![CalculationStatus] aw1! = Gw! aw2! = 0 End If If MainSet![CalculationStatus] = 0 Then GoSub UTDoAnswers If ((Bottom_Trim_Cut! < 2) Or (Bottom_Trim_Cut! >= FirstCut) Or (TOP_TRIM_CUT! >= FirstCut)) And (Multi$ = "MULTIPLE") Then RC% = 5: GoSub Setcalcstat MainSet.Update Exit Sub End If End If Return MainSet.Update Exit Sub UTDoAnswers: If Multi$ = "BLANK" Then FirstCutDir% = 1 Select Case FirstCutDir% Case 1 If (Multi$ = "MULTIPLE") Or (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then Call CalcMultGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!) If Multi$ = "LASER" Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then MainSet![ActualPartHeight] = MainSet![PartHeight] MainSet![ActualPartWidth] = MainSet![PartWidth] Else MainSet![ActualPartHeight] = First_Dim! - TOP_TRIM_CUT! - Bottom_Trim_Cut! MainSet![ActualPartWidth] = MainSet![PartWidth] End If Else Call CalcGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!, RC%) If RC% <> 0 Then GoSub Setcalcstat End If MainSet![ActualPartHeight] = First_Dim! MainSet![ActualPartWidth] = Second_dim! End If If (Multi$ <> "LASER") And (Multi$ <> "SALVAGNINI") And (Multi$ <> "LASER/SHEAR") Then MainSet![PartHeight] = First_Dim! End If FirstCut! = First_Dim! SecondCut! = Second_dim! If ExtraShear% Then MainSet!GrainDir = "Along Second Dimension" fc$ = "Along Second Dimension" Else MainSet!GrainDir = "Along First Dimension" fc$ = "Along First Dimension" End If Case 2 Call CalcGrossWeight(Second_dim!, First_Dim!, Gw!, Aw!, RC%) If RC% <> 0 Then GoSub Setcalcstat End If fc$ = "Along Second Dimension" MainSet!GrainDir = 2 If (Multi$ <> "LASER") And (Multi$ <> "SALVAGNINI") And (Multi$ <> "LASER/SHEAR") Then MainSet![PartHeight] = Second_dim! End If MainSet![ActualPartHeight] = Second_dim! MainSet![ActualPartWidth] = First_Dim! FirstCut! = Second_dim! SecondCut! = First_Dim! Case Else fc$ = MainSet![GrainDir] MainSet![PartHeight] = First_Dim! MainSet![ActualPartHeight] = First_Dim! MainSet![ActualPartWidth] = Second_dim! FirstCut! = First_Dim! SecondCut! = Second_dim! If Multi$ = "BLANK" Then FirstCutDir% = 1 End Select Actual_PartHeight = MainSet![ActualPartHeight] Actual_PartWidth = MainSet![ActualPartWidth] If FirstCutDir% = 0 Then RC% = 1: GoSub Setcalcstat Else MainSet![GrainDir] = fc$ If Aw! > Gw! Then Aw! = Gw! MainSet![GrossWt] = Gw! MainSet![ActualWt] = Aw! MainSet![Utilization] = 0 If Gw! <> 0 Then MainSet![Utilization] = Aw! / Gw! End If MainSet![PartsPerSheet] = parts_per_sheet! MainSet![BlocksPerSheet] = Blocks_Per_Sheet! MainSet![BlanksPerBlock] = Blanks_Per_Block! MainSet![SheetSize] = Format$(Sheet_Width!, "###0.000") + " X " + Format$(Sheet_Length!, "###0.000") If (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then MainSet![PartSize] = Format$(MainSet![PartHeight], "###0.000") + " X " + Format$(MainSet![PartWidth], "###0.000") Else MainSet![PartSize] = Format$(MainSet![ActualPartHeight], "###0.000") + " X " + Format$(MainSet![ActualPartWidth], "###0.000") End If MainSet![BlankSize] = Format$(First_Dim!, "###0.000") + " X " + Format$(Second_dim!, "###0.000") End If ' Call ErrorMessages Return UTCalcMaterialWt: If (Multi$ = "NO CNC") And (Punch$ <> "!NONE!") And (MainSet!PunchOption = 2) And (Sheet_Width <> Second_dim!) Then RC% = 2: GoSub Setcalcstat FirstCutDir% = 0 End If If Multi$ = "MULTIPLE" Or Multi$ = "LASER" Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then If (Sheet_Width <> Second_dim!) And (Not (ExtraShear%)) Then RC% = 2: GoSub Setcalcstat FirstCutDir% = 0 ElseIf (((PartWidth + Pt_Width) * Parts_Per_blank) - Pt_Width > Sheet_Width) And (Multi$ <> "LASER") And (Multi$ <> "SALVAGNINI") And (Multi$ <> "LASER/SHEAR") Then RC% = 3: GoSub Setcalcstat FirstCutDir% = 0 ElseIf (Bottom_Trim_Cut! < 2) And (Multi$ <> "LASER") And (Multi$ <> "SALVAGNINI") And (Multi$ <> "LASER/SHEAR") Then RC% = 5: GoSub Setcalcstat FirstCutDir% = 0 Else Part_Width = MainSet![PartWidth] Call CalcMultGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!) FirstCutDir% = 1 End If Else If Not (GrNone%) Then If Left$(Grain$, 11) = "ALONG FIRST" Then FirstCutDir% = 1 Call CalcGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!, RC%) If RC% <> 0 Then GoSub Setcalcstat End If Else FirstCutDir% = 2 Call CalcGrossWeight(Second_dim!, First_Dim!, Gw!, Aw!, RC%) If RC% <> 0 Then GoSub Setcalcstat End If End If Else Call CalcGrossWeight(First_Dim!, Second_dim!, Gw1!, Aw!, RC%) If RC% <> 0 Then GoSub Setcalcstat End If Call CalcGrossWeight(Second_dim!, First_Dim!, Gw2!, Aw!, RC%) If RC% <> 0 Then GoSub Setcalcstat End If If Gw1! < Gw2! Then FirstCutDir% = 1 Call CalcGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!, RC%) If RC% <> 0 Then GoSub Setcalcstat End If Else FirstCutDir% = 2 Call CalcGrossWeight(Second_dim!, First_Dim!, Gw!, Aw!, RC%) If RC% <> 0 Then GoSub Setcalcstat End If End If If Gw1! = Gw2! Then If First_Dim! < Second_dim! Then FirstCutDir% = 1 Call CalcGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!, RC%) If RC% <> 0 Then GoSub Setcalcstat End If Else FirstCutDir% = 2 Call CalcGrossWeight(Second_dim!, First_Dim!, Gw!, Aw!, RC%) If RC% <> 0 Then GoSub Setcalcstat End If End If End If End If End If Return Setcalcstat: MainSet![CalculationStatus] = RC% Return End Sub Sub CrossRef() currform!cmdDeleteFileFromTrumpfs.Visible = False currform!lblCalcStat.Visible = True currform!txtCalcStat.Visible = True currform!txtCalcStat.Caption = "Searching Cross Reference File." currform!lblXrefMessage.Visible = False Set XrefQDB = DBEngine.Workspaces(0).Databases(0) Set XrefQSet = XrefQDB.OpenRecordset("RMSFILES#_EGSSP1A0", DB_OPEN_DYNASET) ' Create dynaset. If XrefQSet.recordCount <> 0 Then XrefQSet.MoveFirst PartN$ = currform![PartNumber] xPN$ = Left(PartN$, 7) Do Until XrefQSet.EOF If (Trim(XrefQSet!CURPN) = xPN$) Or (Trim(XrefQSet!NEWPN) = xPN$) Then currform!lblXrefMessage.Visible = True currform!lblXrefMessage.Caption = "This part has an associated part - " + Trim(XrefQSet!CURPN) + Right$(PartN, 1) + "/" + Trim(XrefQSet!NEWPN) + Right$(PartN, 1) currform!cmd300Series.Visible = True Exit Do End If XrefQSet.MoveNext Loop End If currform!cmdDeleteFileFromTrumpfs.Visible = True currform!lblCalcStat.Visible = False currform!txtCalcStat.Visible = False currform!txtCalcStat.Caption = "Waiting for Calculate" End Sub ``` ## What it does #### Chunk 1 ## Detailed Description of VBA Code ### Module and Variable Declarations The provided VBA code defines a module named `processvariables` with various global variables. These variables are used to store values related to processing and manufacturing, such as part information, machine details, and production data. ```markdown Attribute VB_Name = "processvariables" Global NewPartName_Parm$, PrimaryScreen$, Initforms$, Parts_per_strip!, blankUnits$ Global Sheet_Width!, Sheet_Length!, Actual_PartHeight!, Actual_PartWidth! Global Trim_Cut!, lb_per_sq_ft!, Blocks_Per_Sheet!, src!, PricePerLB! Global Blanks_Per_Block!, parts_per_sheet!, FirstCut!, SecondCut!, SecondShear Global NoGrDirChange, Multi$, TypeDeburr$, MetalName$, MetalPart$, NoDataSheets% Global Grain$, AddnlI%, Pt_Width!, Location%, Gauge$, PMachine$, DescrW, Denting% Global Parts_Per_blank!, Part_Height!, Bottom_Trim_Cut!, FirstCutDir%, UnivREQName$, CalculatedGrossWeight! Global TOP_TRIM_CUT!, Part_Width!, First_Dim!, Second_dim!, dbtype!(20, 2), warehousewc$ Global Elem!(53), Ds$(40), Internal_Labor!, Internal_Walk!, FontTypes%, ExtraShear% Global YESORNO%, YesOrNoStr$, MachinesWithShears$, OutPutData%, PurchaseBlank%, usrID$ ``` ### Subroutine: `Add_Additional_Process()` The code defines a subroutine named `Add_Additional_Process()` that performs several operations related to processing and manufacturing data. ```markdown Sub Add_Additional_Process() Dim AddnlQDB As Database, AddnlQSet As Recordset Dim AddnlDB As Database, AddnlSet As Recordset Dim MachQDB As Database, MachQSet As Recordset Dim Hopc! PartN$ = currform![PartNumber] If currform!SavedProcesses.ListIndex = -1 Then Exit Sub End If Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set search criteria. Set AddnlQDB = DBEngine.Workspaces(0).Databases(0) Set AddnlQSet = AddnlQDB.OpenRecordset("AddnlQ1", DB_OPEN_DYNASET) ' Create dynaset. Set AddnlDB = DBEngine.Workspaces(0).Databases(0) Set AddnlSet = AddnlQDB.OpenRecordset("AddnlPROC", DB_OPEN_TABLE) ' Create dynaset. wc$ = currform!SavedProcesses.Column(0) Machine$ = currform!SavedProcesses.Column(1) wc1$ = Left$(currform!SavedProcesses.Column(2) + " ", 3) wc2$ = Left$(currform!SavedProcesses.Column(3) + " ", 3) wc3$ = Left$(currform!SavedProcesses.Column(4) + " ", 3) wc4$ = Left$(currform!SavedProcesses.Column(5) + " ", 3) ``` The subroutine performs the following operations: 1. Retrieves the part number from the `PartNumber` field in the current form's data. 2. Checks if there are any saved processes listed. If not, it exits the subroutine. 3. Sets up the database and recordset connections for additional processing data. 4. Extracts specific values from the saved processes column to determine various parameters. However, the code snippet provided does not contain a complete implementation of the `Add_Additional_Process()` subroutine. The actual logic and operations are missing in this part of the code. #### Chunk 2 *Failed to generate documentation with Ollama* #### Chunk 3 *Failed to generate documentation with Ollama* #### Chunk 4 Here is a detailed Markdown description of the VBA code: **AddnlHandDeburr Function** ```markdown ### Description Calculates the deburred length for hand deburring. ### Parameters * `currform!AddnlDeburrInches`: input value (in inches) * Returns: calculated deburred length (`AddnlHandDeburr!`) ### Code ```vba Function AddnlHandDeburr! Addnl = currform!AddnlDeburrInches AddnlHandDeburr! = Addnl * 0.002 * 60 End Function ``` This function takes an input value `currform!AddnlDeburrInches` and multiplies it by a factor of 0.002 \* 60 to calculate the deburred length. **AddPartButton Sub** ```markdown ### Description Opens a new form for adding parts. ### Parameters None ### Code ```vba Sub AddPartButton() On Error GoTo Err_addPr_Click Dim DocName As String Dim LinkCriteria As String DoCmd.Close DocName = "New Process Sheet" DoCmd.OpenForm DocName, , , LinkCriteria Exit_addPr_Click: Exit Sub Err_addPr_Click: MsgBox Error$ Resume Exit_addPr_Click End Sub ``` This sub opens a new form for adding parts. If an error occurs, it displays an error message and continues executing. **CalcActualWt Sub** ```markdown ### Description Calculates the actual weight of a part. ### Parameters * `dim1!`, `dim2!`: input values (length and width) * `Aw!`: output value (actual weight) ### Code ```vba Sub CalcActualWt(dim1!, dim2!, Aw!) If (lb_per_sq_ft! = 0) Then Exit Sub Aw! = dim1! * dim2! / 144 * lb_per_sq_ft! Aw! = Val(Format$(Aw!, "######0.000")) End Sub ``` This sub takes input values `dim1!` and `dim2!` and calculates the actual weight using the formula `Aw! = (length \* width) / 144 \* lb_per_sq_ft!`. The result is stored in output variable `Aw!`. **CalcGrossWeight Sub** ```markdown ### Description Calculates the gross weight of a part. ### Parameters * `dim1!`, `dim2!`: input values (length and width) * `Gw!`: output value (gross weight) * `RC%`: output variable (used for calculations) ### Code ```vba Sub CalcGrossWeight(dim1!, dim2!, Gw!, Aw!, RC%) Dim A%, b% RC% = 0 If (dim1! = 0) Or (dim2! = 0) Or (lb_per_sq_ft! = 0) Then RC% = 6 Exit Sub ASheet_Width! = Sheet_Width! ASheet_Length! = Sheet_Length! If dim1! \u003c 2 Then ASheet_Length! = ASheet_Length! - 2 If dim2! \u003c 2 Then ASheet_Width! = ASheet_Width! - 2 If Multi$ = "BLANK" Then A% = 1 Else A% = Int((ASheet_Width! - Trim_Cut) / dim2!) End If b% = Int((ASheet_Length! - Trim_Cut) / dim1!) C% = 1 'for punch press Parts_per_strip! = 1 If (Multi$ = "NO CNC") Then ... If parts_per_sheet \u003c\u003e 0 Then Gw! = Sheet_Width! * Sheet_Length! / 144 * lb_per_sq_ft! / parts_per_sheet Call CalcActualWt(dim1!, dim2!, Aw!) Aw! = Aw! / Parts_per_strip! Else ... ``` This sub calculates the gross weight of a part using various input values and formulas. The result is stored in output variable `Gw!`. **Unclosed Code Snippet** ```markdown ### Description Unfinished code snippet. ### Parameters None ### Code ... ``` Note that this code snippet appears to be incomplete, as it does not contain a clear function or procedure definition. It may be a fragment of an existing codebase or a starting point for further development. #### Chunk 5 ### Detailed Description of VBA Code #### Sub Calculate GW ```markdown # Calculate Gross Weight (GW) ``` This sub calculates the gross weight of a part based on its dimensions and material properties. * It checks if the unit type is "LB" (pounds). If true, it calculates the gross weight using the formula: `Gw! = Sheet_Width! * Sheet_Length! / 144 * lb_per_sq_ft!`. * If the unit type is not "LB", it sets the gross weight to 1. ```markdown If blankUnits$ = "LB" Then Gw! = Sheet_Width! * Sheet_Length! / 144 * lb_per_sq_ft! ' ... (rest of the calculation remains the same) Else Gw! = 1 End If ``` #### Sub CalcLaborCost ```markdown # Calculate Labor Cost ``` This sub calculates the total labor cost for a part based on its material properties. * It sets up a database and recordset connection to retrieve data from an AddnlQ database. * It loops through each occurrence in the recordset, calculating the labor rate and adding it to the total labor cost (`LaborTot!`). * The loop continues until no more matching records are found. ```markdown Sub CalcLaborCost(LaborTot!) Dim AddnlQDB As Database, AddnlQSet As Recordset ' ... (connection setup remains the same) Do Until AddnlQSet.NoMatch Hopc$ = AddnlQSet!OpCode If InStr(Hopc$, "*") = 0 Then rs! = AddnlQSet!RunStd Lr! = AddnlQSet!LaborRate LaborTot! = LaborTot! + (rs! * Lr!) End If AddnlQSet.FindNext Criteria$ Loop End Sub ``` #### Sub CalcMultGrossWeight ```markdown # Calculate Multigross Weight ``` This sub calculates the multigross weight of a part based on its dimensions and material properties. * It checks if any input values are zero. If true, it exits the subroutine. * It calls the `CalcActualWt` subroutine to calculate the actual weight (`Aw!`) using the given dimensions and material properties. * Based on the extra shear setting, it calculates the blocks per sheet, blanks per block, and parts per sheet. * If the first dimension is equal to the sheet length and the second dimension is equal to the sheet width, it checks a specific condition related to the multi-gross weight calculation. ```markdown Sub CalcMultGrossWeight(dim1!, dim2!, Gw!, Aw!) Dim A!, b! ' ... (input values setup remains the same) If parts_per_sheet! \u003c\u003e 0 Then Gw! = Sheet_Width * Sheet_Length / 144 * lb_per_sq_ft / parts_per_sheet ' Gw! = (Int(Gw! * 1000)) / 1000 Gw! = Val(Format(Gw!, "0.000")) Else If (First_Dim! = Sheet_Length!) And (Second_dim! = Sheet_Width!) ' ... (specific condition related to multi-gross weight calculation remains the same) ``` #### Chunk 6 **Detailed Description of VBA Code** ### Calculated Gross Weight (GW) Subroutine This subroutine calculates the calculated gross weight (`Gw!`) of a part based on various input parameters. ```markdown ' Calculated GW ' Gw! = Sheet_Width! * Sheet_Length! / 144 * lb_per_sq_ft! / Parts_Per_blank ' Gw! = (Int(Gw * 1000)) / 1000 Gw! = Val(Format(Gw!, "0.000")) pw! = ItsAZero!(Part_Width!) Aw! = Part_Height! * pw! / 144 * lb_per_sq_ft! Blocks_Per_Sheet! = 1 parts_per_sheet = Parts_Per_blank ``` Here's what the code does: * Calculates `Gw!` by multiplying `Sheet_Width`, `Sheet_Length`, and converting to pounds using the given conversion factors. * Rounds `Gw!` to three decimal places using `Val()` function and formatting. * Calculates the width (`pw!`) of the part using a separate formula, likely related to trimming or cutting dimensions. * Calculates the area-weighted height (`Aw!`) of the part. * Sets default values for blocks per sheet and parts per sheet. ### Main Subroutine (calcs) This subroutine appears to handle various calculations and logic for a specific application. ```markdown Sub calcs() Dim MachQDB As Database, MachQSet As Recordset Dim MachNQDB As Database, MachNQSet As Recordset ' ' Parting tool width = .2 Pt_Width! = 0.2: Trim_Cut = 0.1 Grain$ = Trim$(UCase$(currform![GrainDir])) MachinesWithShears$ = "C-3C-4C-5C-6C-7C-8C-9V-1V-2V-4C10" ' ' Xref database and recordset handling (commented out) ' ' currform!lblXrefMessage.Visible = False ' ' If wh$ = "90" Then If whl$ = "2" Then currform![CalculationStatus] = 11 Call ErrorMessages Exit Sub End If warehousewc$ = "302" Else If whl$ = "1" Then currform![CalculationStatus] = 11 Call ErrorMessages Exit Sub End If warehousewc$ = "347" End If GrNone% = currform![GrainNone] currform!cmdDeleteFileFromTrumpfs.Visible = False currform!lblCalcStat.Visible = True currform!txtCalcStat.Caption = "Calculations underway" currform!txtCalcStat.Visible = True currform!txtCalcStat2.Visible = True DoEvents OutPutData% = True If GrNone% Then Grain$ = "ALONG FIRST" OutPutData% = False currform!txtCalcStat2.Caption = "Calculating along first dimension" DoEvents GoSub CalcPart prc1 = currform![PartCost] Grain$ = "ALONG SECOND" OutPutData% = True currform!txtCalcStat2.Caption = "Calculating along Second dimension" DoEvents GoSub CalcPart prc2 = currform![PartCost] Debug.Print prc1, prc2 If prc1 \u003c prc2 Then currform!GrainDir = "Along First Dimension" ElseIf prc1 \u003e prc2 Then currform!GrainDir = "Along Second Dimension" Else ... ``` Here's what the code does: * Initializes various variables and sets default values. * Handles warehouse-related logic, including calculating `warehousewc$` based on input values. * Sets visibility and captions for GUI elements (e.g., labels, buttons). * Calls other subroutines or macros based on conditional statements. **Note**: This description is limited by the code's complexity and the need to infer underlying logic without direct access to the entire application context. #### Chunk 7 **Detailed Description of VBA Code** This VBA code appears to be part of a Microsoft Excel add-in or a custom form, and it performs various calculations and checks based on user input. ### Conditional Logic The code starts by checking if a specific condition (`DSF$ = "NONE"`) is met. If true, it sets `NoDataSheets%` to 0. Otherwise, it checks the value of `DSF$` against two other conditions (`"REQ'D"` and any other non-None value) and sets `NoDataSheets%` accordingly. ### Calculation Part The code then enters a new section labeled "CalcPart", which performs several calculations: 1. Resets various form fields to zero. 2. Sets the calculation status to 0. 3. Checks if certain input fields are empty or have default values (e.g., `ItsAZero!(currform![FirstDim])`). 4. Extracts values from specific columns of the current form field (`Gp$ = currform!Field113.Column(1)`). ### Blank and Part Dimensions The code then checks if a "Rotate Sheet for Blanks" condition is met (`If RotateBlank \u003c\u003e 0 Then`). If true, it updates `Sheet_Width!` and `Sheet_Length!` based on the rotated sheet's dimensions. It also sets up various variables related to blank dimensions (e.g., `Location%`, `PricePerLB!`, `PurchaseBlank%`) using input values from columns of the current form field (`itsaNull$(currform!Field113.Column(11))`). ### CNC Operations The code checks if a specific CNC operation is selected (`Multi$ \u003c\u003e "NO CNC"`). If true, it sets `RotateBlank` to 0. It also extracts various punch die and presser options from the form field (`PunchCounter%`, `PunchPresserOptions%`). ### Primary CNC Machine Search The code searches for a primary CNC machine matching the part number entered by the user. It: 1. Creates a dynaset connection to the MachinesQ1 recordset. 2. Sets search criteria using the part number. 3. Loops through the results until it finds a match. If a match is found, it sets `MachQSet` to that recordset and updates the form field caption (`currform!txtCalcStat.Caption = "MP - look for primary machine"`). ### Form Field Updates The code updates various form fields based on user input, including: * Calculated values (e.g., `lb_per_sq_ft!`, `PricePerLB!`) * Conditional display or hiding of other form fields (e.g., `currform!lblCalcStat.Visible = False`) Overall, this code appears to be part of a larger system that provides calculations and checks for CNC operations, including blank dimensions, punch die and presser options, and primary CNC machine searches. #### Chunk 8 **Code Overview** ================ The provided VBA code appears to be a part of an application used for calculating material weights and related calculations. It checks various conditions, performs calculations, and updates form values based on user input. **Section 1: Machining Setup** --------------------------- ```markdown If MachQSet!Prime = True Then If MachQSet!Tool \u003c\u003e "SHR" Then If PMachine$ \u003c\u003e "" Then currform![CalculationStatus] = 16 Call ErrorMessages Exit Sub End If PMachine$ = MachQSet!MachineName PWC1$ = MachQSet!Tool PCTime! = MachQSet!CycleTime End If End If ``` This section checks if the machining setup is valid. It verifies that: * The machine name is not empty (`PMachine$ \u003c\u003e ""`). * The tool used is not "SHR" (`MachQSet!Tool \u003c\u003e "SHR"`). If these conditions are met, it updates the form values and proceeds with the next steps. **Section 2: Find Next Occurrence** ------------------------------- ```markdown MachQSet.FindNext Criteria$ DoEvents Loop ``` This section finds the next occurrence in the MachQSet table based on the specified criteria. It repeatedly loops until no more occurrences are found, allowing for dynamic processing of subsequent records. **Section 3: Error Handling and Form Updates** --------------------------------------------- ```markdown If (PMachine$ = "") And (Multi$ \u003c\u003e "NO CNC") And (Multi$ \u003c\u003e "BLANK") Then currform![CalculationStatus] = 15 Call ErrorMessages Exit Sub End If ... If Multi$ = "LASER" Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then Part_Width! = (Sheet_Width! / Parts_Per_blank) - Pt_Width! Bottom_Trim_Cut! = 0 TOP_TRIM_CUT! = 0 If (Multi$ = "LASER/SHEAR") Then Part_Width! = (Second_dim! / Parts_Per_blank) - Pt_Width! End If ``` This section checks for various conditions, including: * Error handling: It ensures that the form fields are updated correctly and handles errors as needed. * Material type calculation: Based on the multi-value selection (`Multi$`), it calculates the part width, bottom trim cut, and top trim cut values. **Section 4: Cell Deburr Types and Metal Name** --------------------------------------------- ```markdown Celltype$ = UCase$(currform![CellDeburrTypes]) MetalName$ = UCase(currform!Field113.Column(0)) If Celltype = "TIME SAVER" Then If ((Not (InStr(MetalName$, "COLD ROLL") = 0) And (Not (InStr(MetalName$, "S/S") = 0)))) Then ' aluminized currform![CalculationStatus] = 19 Call ErrorMessages Exit Sub End If End If ... Celltype$ = UCase$(currform![CellDeburrTypes]) ``` This section updates the cell deburr types and metal name based on user input. It also includes a check for time-saving materials, which triggers an error message if certain keywords are present in the metal name. **Section 5: Material Weight Calculation** -------------------------------------- ```markdown If Multi$ \u003c\u003e "BLANK" Then Calcerr0% = currform![CalculationStatus] GoSub CalcMaterialWt calcerr1% = currform![CalculationStatus] aw1! = Gw! aw2! = 0 If alt = 1 And Multi$ \u003c\u003e "MULTIPLE" Then currentMetal$ = currform![MetalType] currform![MetalType] = itsaNull$(currform!Field113.Column(7)) ``` This section initiates the material weight calculation process for non-blank values of `Multi$. It calls a subroutine (`CalcMaterialWt`) and updates form fields accordingly. **Section 6: Final Calculations** ------------------------------ ```markdown If (First_Dim! = 0) Or (Second_dim! = 0) Or (lb_per_sq_ft! = 0) Then currform![CalculationStatus] = 6 Call ErrorMessages Exit Sub End If ... lb_per_sq_ft! = ItsAZero!(currform!Field113.Column(5)) ``` This section checks for potential errors in the calculations, such as missing dimensions (`First_Dim` and `Second_dim`) or zero weight per square foot (`lb_per_sq_ft`). If any of these values are incorrect, it triggers an error message. #### Chunk 9 **VBA Code Description** ========================== This VBA code appears to be part of a larger program for calculating the weight and cost of materials for metal parts. The code is organized into several sections, each handling specific calculations and validation checks. ### Section 1: Calculation and Validation ----------------------------------------- The first section calculates various parameters based on user input. It: * Checks if certain fields are zero or blank (`ItsAZero!(currform!Field113.Column(x))`) and assigns default values if necessary. * Calculates the calculation status and sets it to `Calcerr0%` if required calculations need to be performed. * Calls the `CalcMaterialWt` subroutine to calculate material weights. ### Section 2: Rotation and Blank Handling ----------------------------------------- The second section checks for blank rotation requirements: * Checks if the `GrainShear` field is zero or blank (`ItsAZero!(currform![GrainShear])`) and assigns a default value of 0 if necessary. * If not, it sets `RotateBlank` to 1, which affects subsequent calculations. ### Section 3: Density Change --------------------------- The third section calculates the density change: * Checks if certain fields are zero or blank (`ItsAZero!(currform!Field113.Column(x))`) and assigns default values if necessary. * Calculates `lb_per_sq_ft!` based on user input. ### Section 4: Main Logic ---------------------- The main logic of the code is executed when `currform![CalculationStatus] = 0`. It: * Calls the `DoAnswers` subroutine to perform additional calculations and validation checks. * Checks if the part size is suitable for a time saver (`currform!ActualPartHeight \u003c 5` and `currform!ActualPartWidth \u003c 5`) and sets an error message if not. * Checks if the bottom trim cut or top trim cut exceeds certain values, setting an error message if necessary. Also checks if the multiple value is set to "MULTIPLE". * Calls the `MakeProcesses` subroutine and the `CalcPrice` subroutine (not shown in this code snippet). * Calculates the blank weight and sets a warning message if it exceeds 50 pounds. ### Section 5: DoAnswers Subroutine --------------------------------- The `DoAnswers` subroutine performs additional calculations and validation checks: * Checks if the multiple value is set to "BLANK" and assigns a default direction value (`FirstCutDir%`) if necessary. * Selects a case based on the direction value: * For "MULTIPLE", "LASER", "SALVAGNINI", "LASER/SHEAR", or "SLUG" values, it calls `CalcMultGrossWeight` and calculates the gross weight. * Otherwise, it calls `CalcGrossWeight`, checks if the result is valid (`RC% \u003c\u003e 0`), and assigns an error message if necessary. It also sets the actual part height and width. **Key Functions and Subroutines** --------------------------------- * `ItsAZero!(currform!Field113.Column(x))`: Checks if a field value is zero or blank. * `GoSub CalcMaterialWt`: Calls the `CalcMaterialWt` subroutine to calculate material weights. * `GoSub DoAnswers`: Calls the `DoAnswers` subroutine for additional calculations and validation checks. * `CalcMultGrossWeight`, `CalcGrossWeight`, `MakeProcesses`, `CalcPrice`, and `PurgeCNCs`: These are assumed to be defined elsewhere in the codebase. **Notes** --------- This VBA code appears to be part of a larger program for calculating metal part weights and costs. The code is organized into sections, each handling specific calculations and validation checks. The code uses various functions and subroutines to perform these tasks. #### Chunk 10 **Code Description** This VBA code appears to be part of a larger program used for calculating costs and properties of metal parts. The code is organized into several sections, each handling specific calculations and updates to the form data. ### Section 1: Initial Checks and Updates ```markdown If (Multi$ \u003c\u003e "LASER") And (Multi$ \u003c\u003e "SALVAGNINI") And (Multi$ \u003c\u003e "LASER/SHEAR") Or (Multi$ = "SLUG") Then currform![PartHeight] = First_Dim! End If ``` This section checks the value of `Multi$` and updates the `PartHeight` field in the form data if it matches specific conditions. ```markdown FirstCut! = First_Dim! SecondCut! = Second_dim! ``` These lines update two additional form fields, `FirstCut` and `SecondCut`, with values from previously defined variables. ### Section 2: Shear Direction and Cut Length ```markdown If ExtraShear% Then fc$ = "Along Second Dimension" currform!GrDirOpt = 2 Else fc$ = "Along First Dimension" currform!GrDirOpt = 1 End If ``` This section determines the shear direction and updates corresponding form fields based on the value of `ExtraShear`. ### Section 3: Case Logic ```markdown Case 2 Call CalcGrossWeight(Second_dim!, First_Dim!, Gw!, Aw!, RC%) If RC% \u003c\u003e 0 Then currform![CalculationStatus] = RC% Call ErrorMessages End If ``` This section handles a specific case logic, calling the `CalcGrossWeight` function and updating form fields based on its return value. ### Section 4: Grain Direction and Part Properties ```markdown fc$ = "Along Second Dimension" currform!GrDirOpt = 2 If (Multi$ \u003c\u003e "LASER") And (Multi$ \u003c\u003e "SALVAGNINI") And (Multi$ \u003c\u003e "LASER/SHEAR") Or (Multi$ = "SLUG") Then currform![PartHeight] = Second_dim! End If currform![ActualPartHeight] = Second_dim! currform![ActualPartWidth] = First_Dim! FirstCut! = Second_dim! SecondCut! = First_Dim! ``` This section updates form fields with values from the `Second_dim` variable and sets up part properties. ### Section 5: Deburr Type and Celltype$ ```markdown If (currform![ActualPartHeight] \u003e= 19) Or (currform![ActualPartWidth] \u003e= 19) Then currform![CellDeburrTypes] = "Hand Deburr" Celltype$ = UCase$(currform![CellDeburrTypes]) End If ``` This section checks for deburring conditions and updates the `Celltype` field accordingly. ### Section 6: Calculation and Updating Form Fields ```markdown If FirstCutDir% = 0 Then currform![CalculationStatus] = 1 Else Call CalcActualWt(Actual_PartHeight!, Actual_PartWidth!, Aw!) 'per Rick Bergeson 10-Oct-2006 ``` This section handles a specific calculation and updates form fields based on the result. ### Section 7: Cost Calculations ```markdown CalcPrice: ' ' Cost Calculations ' Call CalcLaborCost(LaborTot!) If PurchaseBlank% Then currform![MaterialCost] = Val(Format(PricePerLB!, "#####0.####")) Else currform![MaterialCost] = Val(Format(Gw! * PricePerLB!, "#####0.####")) End If ``` This section performs cost calculations using the `CalcLaborCost` and updates form fields with material costs. ```markdown currform![PartCost] = currform![MaterialCost] + currform![LaborCost] Debug.Print currform![MaterialCost], currform![LaborCost], currform![PartCost] Return ``` These lines update the part cost and print debug information to the console. #### Chunk 11 **Code Description** ===================== This is a VBA script written in Microsoft Access, which appears to be part of an application for calculating material weights and cutting directions for CNC parts. The code consists of three main sections: conditional logic, calculation functions, and error handling. ### Conditional Logic ---------------------- The first section checks the values of various variables and sets the `CalculationStatus` field in a form object (`currform`) to different values based on these conditions: ```markdown * If the part is not for CNC (Multi$ = "NO CNC") and the punch press option is set to 2, update the calculation status. * If the part is for multiple parts (Multi$ = "MULTIPLE", etc.) or laser/shear operations, check additional conditions before updating the calculation status. ``` ### Calculation Functions ------------------------- The script then calls various calculation functions to determine the material weight and cutting direction: ```markdown * Call CalcMultGrossWeight with first dimension, second dimension, gross weight, and other parameters. * Call CalcGrossWeight with different combinations of dimensions, gross weights, and parameters. ``` These calculations appear to be used to determine the material weight and cutting direction based on various factors, such as part type, operation, and dimensions. ### Error Handling ------------------ The script includes error handling mechanisms: ```markdown * Call ErrorMessages to display an error message if a calculation returns a non-zero value. * GoTo Bad_Record if an error occurs while processing the data. ``` This section ensures that any errors encountered during calculations are handled and reported to the user. ### Button Click Event ------------------------- The `Calculate_Button` event appears to be triggered when a button is clicked. It: ```markdown * Displays a loading message using DoCmd.Hourglass True. * Checks if the part number field is not empty. * Retrieves the value of the Field113 column in the current recordset (Gp$). ``` This section likely handles the button click event and starts the calculation process. ### Initialize Form Data ------------------------- The `Calculate_All` function initializes the form data by: ```markdown * Refreshing the current form object. * Retrieving the part number from the database. ``` This section sets up the initial conditions for calculating material weights and cutting directions. #### Chunk 12 Here is a detailed Markdown description of the provided VBA code: **Main Procedure** The main procedure is an subroutine that contains various error handling and calculation methods for a CNC milling machine. It checks for different errors and handles them accordingly. ### Error Handling The code uses `On Error GoTo` statements to redirect the execution flow when an error occurs. There are several error handling cases: * **NoMaterialSelected**: Sets the `CalculationStatus` field of the form to 11. * **NoFirstDim**: Sets the `CalculationStatus` field of the form to 12. * **NoCutType**: Sets the `CalculationStatus` field of the form to 13. * **NoDeburr**: Sets the `CalculationStatus` field of the form to 14. * **Bad_Record**: Sets the `CalculationStatus` field of the form to 7 and resumes execution. ### Calculation Methods The code defines a `Function CalculateRec()` that calls the `Calculate_All()` method. This function is not shown in the provided code snippet but is likely responsible for performing various calculations based on the input parameters. ### CNC Operations The code contains several subroutines related to CNC operations: * **CheckGrainShear()**: Checks if a specific type of cut (e.g., Laser, Salvagnini) is being used and updates the visibility of certain form fields accordingly. * **ckPrimaryScreen()**: Updates the `DocName$` variable based on whether the "Process Sheet" or "14 Process Sheet" template is being used. ### CNC Database Selection The code defines a subroutine called `CNC_Verbage()` that takes a database selection value (`DbSel%`) and performs various actions: * For **DbSel% = 1**, it checks if an additional hand deburr operation needs to be performed. If so, it updates the `vb$` variable with the corresponding text and adds "HANDDEBURR" to the CNC database. * For **DbSel% = 2**, it performs a more complex set of actions based on the value of `Multi$`. This includes updating the `prm$` variable and adding "TIMESAVER" to the CNC database. * For **DbSel% = 3**, it performs an additional check for hand deburr operations and updates the `vb$` variable accordingly. Note that some parts of the code, such as the `ds_add()` method, are not shown in the provided snippet and may require additional context or knowledge to fully understand. #### Chunk 13 **Detailed Markdown Description of VBA Code** This VBA code appears to be part of a larger program, likely used for generating text descriptions or instructions related to metalworking processes. The code is structured around different cases, each representing a specific process or set of processes. ### Overview The code initializes an empty string `vb$` and appends various phrases and keywords to it based on the current case number. These phrases describe hand deburring operations performed on edges of a workpiece. ### Detailed Breakdown 1. **Initial Case (Case 1)** - The code appends the phrase "SHEAR \u0026 HAND DEBURR (1) EDGE" to `vb$`. - It then calls the `ds_add` subroutine, adding an entry with key `"HANDDEBURR"` and value `"AEdg"`. This suggests that this case is related to deburring a single edge using hand deburr tools. 2. **Subsequent Cases (Cases 4-9)** - These cases follow similar patterns: * Append phrases to `vb$` describing the specific processes. * Call `ds_add` subroutine with relevant keys and values, adding entries for "HANDDEBURR", "PEDESTAL", and/or "MULTSHEAR". - The process description and deburring details change based on whether an additional hand deburr operation is performed (`AddnlHandDeburr!() = 0`). 3. **Timing-Saving Operations (Case 7)** - In this case, the code appends a description mentioning the use of a timesaver device. - The key `"TIMESAVER"` and value `"SHRD"` are added to the `ds_add` subroutine. 4. **Multi-Tool Processes (Cases 8 and 9)** - These cases describe processes involving multiple tools, including shears, deburrers, and pedestal grinders. - They append phrases to `vb$`, add entries for `"HANDDEBURR"`, `"PEDESTAL"`, and `"MULTSHEAR"` using `ds_add` subroutine. ### Conclusion This VBA code is used to generate descriptive text related to various metalworking processes, specifically hand deburring operations. It uses conditional logic based on case numbers to determine the exact process details, including additional tools or techniques. #### Chunk 14 **VBA Code Description** ========================== This VBA code appears to be part of a larger application that automates various machining operations. The code is organized around different cases, each corresponding to a specific operation or setup. ### Case 10: TimeSaver with Multishear * Adds the "TIME-SAVER" and "MULTISHEAR" commands to the `ds` object array. * Appends additional text to the `vb$` string variable indicating the use of TimeSaver for shearing. * Calls the `Add_Shear_Verbage` subroutine with the updated `vb$` string. ### Case 11: Slug Operation * Checks if the `Multi$` variable is set to "LASER", "SALVAGNINI", or a combination thereof. * If true, sets the `slugispart%` variable to `False` and extracts the `prm$` value from the `PMachine` string. * Selects a specific case based on the `prm$` value: + If the selected case indicates a need for hand deburring, adds the "HANDDEBURR" command to the `ds` object array. + Updates the `vb$` string variable accordingly. ### Case 12: Hand Deburring with Pedestal Grinder * Checks if the `AddnlHandDeburr!` function returns a non-zero value. * If true, updates the `vb$` string variable to indicate hand deburring using a pedestal grinder. * Adds the "HANDDEBURR" command to the `ds` object array. ### Case 13: Hand Deburring with Shear * Checks if the `AddnlHandDeburr!` function returns a non-zero value. * If true, updates the `vb$` string variable to indicate hand deburring with shear. * Adds the "HANDDEBURR" command to the `ds` object array. ### Case 14: Multishear * Updates the `vb$` string variable to indicate multishear operation. * Calls the `Add_Shear_Verbage` subroutine with the updated `vb$` string. ### Case 15: TimeSaver and Multishear * Updates the `vb$` string variable to indicate use of TimeSaver for shearing. * Adds the "TIME-SAVER" command to the `ds` object array. ### Case 16: TimeSaver, Multishear, and Shear * Updates the `vb$` string variable to indicate use of TimeSaver for shearing. * Calls the `Add_Shear_Verbage` subroutine with the updated `vb$` string. ### Default Case The code includes an "Else" clause that handles any cases not explicitly covered by the previous cases. However, the exact behavior in this default case is unclear without further context or code. #### Chunk 15 **CutTypeFormSettings Subroutine** ===================================== The `CutTypeFormSettings` subroutine is a VBA function that dynamically sets the visibility of various form controls within a user interface based on the current value of the `currform.CutType` property. ### Functionality This subroutine is designed to display or hide different sections of a form depending on the type of cutting operation selected. The form contains various input fields, buttons, and labels that are used to configure settings for cutting operations such as single part cuts, multiple part cuts, laser cuts, and CNC tape calculations. ### Conditional Logic The subroutine uses a `Select Case` statement to evaluate the value of `currform.CutType`. Based on the value, it sets the visibility of different form controls using the `Visible` property. The conditions are as follows: * **Single**: Shows fields related to single part cuts, such as rotation blank settings and parts per blank. * **Multiple**: Displays fields for multiple part cuts, including rotation blank settings and blanks per block. * **Laser**, **Laser/Shear**, **Slug**, **Salvagnini**: Shows fields associated with laser cutting operations, including rotation blank settings and CNC tape calculations. Also displays blanks per block field when "Laser/Shear" is selected. * **No CNC**: Hides all fields related to CNC operations. ### Control Visibility The subroutine sets the visibility of various controls as follows: * `chkRotateBlank` and `lblRotateBlank`: Always visible or hidden based on the cut type. * `PartsPerBlank`, `BotTrimCut`, `PartWidth`, `TopTrimCut`, `SubForm2`, `Button200`, `CalcCNCtape`, `Text232`, and `EntPartHeight`: Visible or hidden depending on the selected cut type. * `BlanksPerBlock`: Visible or hidden based on the selected cut type, with special handling for "Laser/Shear" cuts. ### Exit Sub If no specific cut type is selected (i.e., an unknown value), the subroutine uses the default case to set all controls to their visible state. By using this subroutine, the user interface can be dynamically configured based on the selected cutting operation, providing a more adaptive and user-friendly experience. #### Chunk 16 **Detailed Description of VBA Code** This VBA code is written in Access and appears to be a part of a larger application for managing machine parts. It consists of two main subroutines: `UpdateForm` and `Delete_Part`. ### UpdateForm Subroutine The `UpdateForm` subroutine is responsible for updating the visibility of various controls on a form (`currform`) based on different conditions. ```markdown **Visibility Control Logic** The subroutine uses a `Select Case` statement to determine the visibility of several controls. The case values are "Blank" and "Else". * When the condition is "Blank", certain controls become visible, while others remain hidden or are set to invisible. * Conversely, when the condition is not "Blank", the opposite logic applies. **Key Control Visibility Logic** ```markdown ' Blank conditions currform!chkRotateBlank.Visible = True currform!lblRotateBlank.Visible = True currform!PartsPerBlank.Visible = False currform!BotTrimCut.Visible = False currform!TopTrimCut.Visible = False currform!PartWidth.Visible = False currform!SubForm2.Visible = False currform!Button200.Visible = False currform!CalcCNCtape.Visible = False currform!Text232.Visible = False currform!EntPartHeight.Visible = False ' Else conditions currform!chkRotateBlank.Visible = False currform!lblRotateBlank.Visible = False currform!PartsPerBlank.Visible = False currform!BotTrimCut.Visible = False currform!TopTrimCut.Visible = False currform!PartWidth.Visible = False currform!SubForm2.Visible = False currform!Button200.Visible = False currform!CalcCNCtape.Visible = False currform!Text232.Visible = False currform!EntPartHeight.Visible = False ``` ### Delete_Part Subroutine The `Delete_Part` subroutine performs the following tasks: ```markdown **Database and Form Management** * Establishes connections to various databases (`MainDB`, `Main2DB`, `MachNamesDB`, `MachQDB`) and sets up Recordsets (`MainSet`, `Main2Set`, `MachNamesSet`, `MachQSet`). * Refreshes the current form (`currform`) and retrieves the part number from the `PartNumber` control. **Delete Part Logic** The subroutine checks for the existence of a record with the specified part number in the main database. If a match is found, it moves to the previous or first occurrence and then deletes the record if necessary. ```markdown GoSub OPEN_Machs GoSub DeleteEm MainSet.Seek "\u003e=", PN$ If Not (MainSet.NoMatch) Then MainSet.MovePrevious If Not (MainSet.BOF) Then px$ = MainSet!PartNumber End If End If Do While Trim$(MainSet!PartNumber) = PN$ MainSet.Delete MainSet.MoveNext If (MainSet.EOF) Then Exit Do Loop ``` **Exit and Cleanup** The subroutine exits the `Delete_Part` procedure if no matches are found. It then cleans up by moving to the next part number in the main database (`GoSub OPEN_Machs`) and deleting any remaining records. ```markdown DeleteEm: MainSet.Seek "\u003e=", PN$ If Not (MainSet.NoMatch) Then Do While Trim$(MainSet!PartNumber) = PN$ MainSet.Delete MainSet.MoveNext If (MainSet.EOF) Then Exit Do Loop ``` ### Additional Logic The subroutine also performs additional logic, including updating the material information display and calling two subroutines (`CheckGrainShear` and `PunchPressOptions`) to handle grain shear and punch press options. #### Chunk 17 **VBA Code Description** ========================== This VBA code is used to open and interact with various databases in a Microsoft Access environment. The code consists of two main subroutines: `Det_CNC_Highest_Runtime` and the `OPEN_*` subroutines. ### OPEN_* Subroutines The `OPEN_*` subroutines are used to open multiple dynamic recordsets (dynaset) in separate databases (`MainDB`, `Main2DB`, etc.). The subroutines set the index for each recordset and then return, indicating that the dynaset is now available for use. Each `OPEN_*` subroutine follows a similar pattern: 1. Open a new dynaset using `MainDB.OpenRecordset("Table Name", DB_OPEN_TABLE)`. 2. Set the index for the recordset using `MainSet.Index = "Index Field"`. 3. Return, indicating that the dynaset is now available. The subroutines are used to access different databases and tables, such as: * `OPEN_Mains`: opens the `Process`, `Main2DB`, and other records. * `OPEN_Addnl`: opens the `AddnlProc` recordset. * `OPEN_Machs`: opens the `Machines` recordset. * `Open_Data`: opens the `DataSheet` recordset. * `OPEN_Press`: opens the `PressBrakeOps` recordset. ### Det_CNC_Highest_Runtime Subroutine The `Det_CNC_Highest_Runtime` subroutine is used to find the CNC machine with the highest runtime for a given part number. The subroutine takes three parameters: * `PartN$`: the part number to search for. * `CNC_Highest_RunTime!`: the variable to store the highest runtime. * `REPOSITION_FLAG$`: an optional parameter (not used in this code snippet). The subroutine follows these steps: 1. Sets the criteria for the search using `Criteria$ = "PartNumber = '" + PartN$ + "'"`. 2. Opens a new dynaset using `MachQDB.OpenRecordset("MachinesQ1", DB_OPEN_DYNASET)`. 3. Finds the first occurrence of the criteria and extracts relevant data from the recordset. 4. Loops through the remaining records in the dynaset, finding the next occurrence of the criteria and extracting relevant data. 5. Stores the highest runtime in the `CNC_Highest_RunTime!` variable. However, this code snippet is incomplete, as it contains an error handling block (`On Error GoTo toolset`) that is not properly implemented. The code also appears to be missing some necessary steps or variables (e.g., `MAX_PERCENTAGE_OVER_LOWEST_RUNTIME`, `MachNQDB`, and `MachNQSet`). #### Chunk 18 **Code Description** This VBA code is a combination of two separate subroutines: `Det_CNC_Standard` and an unnamed subroutine that appears to be responsible for finding CNC tooling information. ### Unnamed Subroutine #### Purpose The unnamed subroutine's purpose is to find the highest runtime of a specific machine (CNC) tool. It iterates through a database of CNC tools, calculates their runtimes, and updates variables `MAX_HIGHEST_RUNTIME` and `CNC_Highest_RunTime`. #### Steps: 1. The code starts by setting up initial values for `LOWEST_RUNTIME`, `REPOSITION_FLAG$`, and the machine names `MN$`. 2. It then loops through the database using `MachQSet.FindNext Criteria$` until it finds a matching record. 3. For each match, it extracts relevant information (cycle time, tool name, etc.) from the database and calculates the runtime. 4. The code checks if the machine name matches certain criteria (`C-1000` or `C-2000`) to determine whether to update the `ck` variable. 5. If the `ck` variable is 1, it updates the `CNC_Highest_RunTime` variable and sets the `REPOSITION_FLAG$`. 6. The code repeats steps 2-5 until all records are processed. #### Variables Used: * `MachQSet`: an object that provides access to a database of CNC tools * `Cy!`: the cycle time of a machine * `LOWEST_RUNTIME`, `CNC_Highest_RunTime`: variables that store the lowest and highest runtime values, respectively * `REPOSITION_FLAG$`: a flag that indicates whether a tool needs repositioning * `ck`: a variable used to determine whether a tool is eligible for consideration #### Error Handling: The code includes an error handling mechanism (`toolset`) that catches any errors that occur during the execution of the loops. If an error occurs, it sets `TL$` to an empty string and resumes processing. ### Subroutine Det_CNC_Standard #### Purpose This subroutine is responsible for determining the CNC standard based on certain conditions. #### Steps: 1. The code starts by activating a form (`currform`) and setting up variables related to the CNC standard calculation. 2. It then checks if the machine name `PMachine$` matches specific criteria (e.g., "C-3000" or "V-1000"). 3. Depending on the match, it adjusts the `CNC_Pfd` value. 4. The code calculates the blank weight and uses it to determine the load and unload times for a press operation. 5. It then sets up variables related to the calculation of the CNC standard. #### Variables Used: * `CNC_Pfd`: a variable that stores the CNC pressure feed rate * `Blank_wt`: the blank weight used in calculating the load and unload times * `LOAD_TIME`, `UNLOAD_TIME`: variables that store the load and unload times, respectively #### Calculation of CNC Standard: The code includes calculations for the CNC standard based on the machine name and blank weight. These calculations involve multiplying the lowest runtime value by a percentage over the lowest runtime (`MAX_PERCENTAGE_OVER_LOWEST_RUNTIME`). #### Chunk 19 **CNC Standard Time Calculation and Deburr Run Times** ===================================================== This VBA code calculates the standard time for a CNC operation, including deburr run times, based on various parameters. The calculation involves multiple steps and subroutines. ### Section 1: Calculating Unload Time The first section of the code determines the unload time based on the Blank Weight (`Blank_wt`). The unload time is calculated using a series of `If` statements: * If `Blank_wt` is between 4 and 8, the unload time is set to 0.04 seconds. * If `Blank_wt` is between 8 and 12, the unload time is set to 0.041 seconds. * If `Blank_wt` is between 12 and 20, the unload time is set to 0.042 seconds. * If `Blank_wt` is greater than 20, the unload time is set to 0.043 seconds. ### Section 2: Calculating Standard Time The second section of the code calculates the standard time for the CNC operation: 1. **Calculating Machine Cycle**: The machine cycle is calculated by dividing the highest run time (`CNC_Highest_RunTime`) by 60. 2. **Assigning values to Elements**: Values are assigned to specific elements in the spreadsheet: * `Elem!(23)` = `CNC_Highest_RunTime` * `Elem!(24)` = 60 * `Elem!(22)` = Machine Cycle 3. **Checking Reposition Flag**: If the Reposition Flag (`Repostition_Flag$`) is set to "R/S", the standard time is set to the repositioning time (`REPOSITION_TIME`). 4. **Adding Major Dimension Time**: If either the first or second dimension is greater than the major dimension, an additional amount of time is added to the standard time (`Major_Dim_Time`). ### Section 3: Calculating Standard Time Components The third section of the code calculates various components that contribute to the standard time: 1. **Calculating Load Time**: The load time is assigned to `Elem!(6)`. 2. **Calculating Activate Press Time**: The activate press time is assigned to `Elem!(10)`. 3. **Calculating Unload Time**: The unload time is assigned to `Elem!(18)`. 4. **Calculating Paper Work**: The paper work is assigned to `CNC` and then calculated based on the total select time (`Elem!(1)`), parts per blank (`ppb`), and an overhead factor (`CNC_Pfd`). ### Section 4: Deburr Run Times The fourth section of the code calculates deburr run times using various subroutines: * `Det_Deburr_Run_Times`: This subroutine performs multiple calculations, including: + Calculating RU_PER_PACE (paces per unit) + Determining deburr run times for different operations (`SHEAR`, `TS`, `HDB1`, `HDB2`, `hdb4`) * `Calc_Mult_Hnd_DB` to `Calc_Shear`: These subroutines perform calculations related to the deburr run times. ### Section 5: Final Calculations and Assignments The final section of the code assigns values to elements in the spreadsheet based on the calculated standard time: 1. **Assigning standard time**: The standard time (`CNC_STD`) is assigned to `CNC`. 2. **Calculating Deburr Run Times**: Various deburr run times are calculated and assigned to specific elements. Overall, this VBA code calculates the standard time for a CNC operation, including deburr run times, based on various parameters and subroutines. #### Chunk 20 **Pedestal Grinder Simulation Subroutine** ===================================== This VBA subroutine simulates the operation of a pedestal grinder, calculating the processing time for each process step and determining the quickest completion time. ### Variables and Constants * `ahdb!`: Accumulated height of material * `PDB1!`, `PDB2!`, `PDB4!`: Processing times for different processes * `RU_PER_PACE`: Rate per pace value * `CNCTime!`: Connection time limit * `Complete%`: Completion percentage * `Quickest`: Index of the quickest process step * `dbproc`: Process index (from 1 to 16) * `dbtype!(dbproc, 0)`, `dbt!`: Data type values for processes * `SHEAR!`, `TShear!`: Shear and timesaver values * `HDB1!`, `HDB2!`, `hdb4!`: HDB values * `MultiNoParts`: Multiplier value for parts count ### Subroutine Flow The subroutine starts by initializing variables and constants. 1. **Calculate processing times**: The subroutine calls the `Det_Pedestal_Grinder_Standard` function to calculate the processing times for each process step (`PDB1!`, `PDB2!`, `PDB4!`). These values are then multiplied by 60 to convert them from seconds to minutes. 2. **Loop through process steps**: The subroutine loops through the process steps (from 1 to 16) and checks if the current process is a pedestal grinder process (`dbtype!(dbproc, 0) = 1`). 3. **Update completion time**: If the current process is a pedestal grinder process, the subroutine updates the completion time using the `Quickest` variable. 4. **Check connection time limit**: The subroutine checks if the calculated completion time exceeds the connection time limit (`CNCTime!`). If it does, the completion time is set to 1 (i.e., complete). 5. **Exit loop early**: If the completion time is complete, the subroutine exits the loop. 6. **Update Quickest process**: The subroutine updates the `Quickest` variable with the index of the quickest process step. ### Process Step Subroutines The subroutine contains several process step subroutines (`dbp1` to `dbp9`) that calculate the processing time for each process step. These subroutines update the `Complete%`, `Paces!`, and `dbt!` variables based on the calculated processing time. Each process step subroutine follows a similar pattern: * Calculate the processing time using the `Det_Pedestal_Grinder_Standard` function. * Update the `Complete%` variable based on the processing time. * Update the `Paces!` variable based on the processing time. * Return to exit the sub routine. ### Exit Subroutine The subroutine exits by calling the `Exit Sub` statement, which ends the subroutine execution. #### Chunk 21 **Detailed Markdown Description of VBA Code** ### Overview This VBA code is used to calculate labor time for hand deburring operations in a manufacturing process. It determines the required labor time based on various factors such as part dimensions, deburring method, and additional features. ### Database Operations The code operates on a database system, using variables such as `dbp10`, `dbt!`, `Paces!`, and `%` to store and retrieve data. The variables are used to calculate the labor time for different deburring operations (e.g., `dbp11`) and update the database accordingly. ### Subroutine: Det_HandDeburr This subroutine is the main entry point of the code, taking three parameters: * `Labor!`: Output variable to store the total labor time. * `Rstd!`: Output variable to store the standard hours. * `HDB%`: Input variable representing the deburring method (1-5). The subroutine performs the following tasks: 1. **Deburring Method Determination**: Based on the value of `HDB%`, it determines the required labor time and updates the variables accordingly. 2. **Part Dimension Calculation**: It calculates the part dimensions, including the length, width, and height, based on the deburring method. 3. **Additional Features**: For certain deburring methods (e.g., `HDB = 4`), it adds additional features to the part, such as top trim cut, and updates the part dimensions accordingly. 4. **Labor Time Calculation**: It calculates the labor time using the updated part dimensions and additional features. 5. **Database Update**: The subroutine calls another function (`Elem_Add`) to update the database with the calculated labor time. 6. **Variable Updates**: It updates various variables, including `dbt!`, `Paces!`, `%`, and others, based on the deburring operation. ### Calculation Logic The code uses a combination of arithmetic operations, conditional statements, and loops to calculate the labor time for different deburring operations. The calculations are based on the part dimensions, deburring method, and additional features. Here's a simplified explanation of the calculation logic: * For `HDB = 1`, it calculates the labor time as twice the actual part width. * For `HDB = 2`, it calculates the labor time as twice the actual part length. * For `HDB = 3`, it calculates the labor time based on the part height and width, considering additional features like top trim cut. * For `HDB = 4` and `HDB = 5`, it uses a different calculation logic to determine the labor time. The code also updates various variables, such as `dbt!` and `Paces!`, based on the deburring operation. The `%` variable is used to store the completion percentage of the deburring operation. Overall, this VBA code provides a structured approach to calculating labor time for hand deburring operations in a manufacturing process. #### Chunk 22 **VBA Code Description** ======================== ### Sub Det_Shake This subroutine calculates the shake and break time for a specific part. #### Purpose The purpose of this subroutine is to determine the shake and break time for a given part based on its type. The output values are stored in an array called `Elem!` which can be accessed later in the code. #### Parameters * `ForP$`: A string indicating the type of part (e.g., "F" for Fab Shake n Break, "FM" for certain metals and difficulties in safety handling) * `Rstd!`: An output parameter to store the standard time for the part #### Code Flow 1. The subroutine sets up a caption on a form to indicate that it is running. 2. It retrieves the Part Number from a form called `currform`. 3. Based on the value of `ForP$`, it selects different values for `Elem1!` and `Elem2!`. These values are used to calculate the labor time. 4. The labor time is calculated as the sum of `Elem1!` and `Elem2!`. 5. Other values in the `Elem!` array are populated with default or calculated values. 6. The standard time (`Rstd!`) is set to the value of `Elem!(5)`. 7. A message is added to a log for the part called "SHAKEBREAK". ### Sub Det_LASER_Standard This subroutine calculates the laser standard time for a specific part. #### Purpose The purpose of this subroutine is to determine the laser standard time for a given part based on its dimensions and machine settings. #### Parameters * `PN$`: The Part Number of the part * `Rstd!`: An output parameter to store the standard time for the part * `ctime!`: An input parameter to store the cycle time #### Code Flow 1. The subroutine sets up database objects to interact with a database. 2. It searches for the first occurrence in a recordset called "MachinesQ1" that matches the Part Number. 3. Once found, it retrieves the machine name, tool, and cycle time from the recordset. 4. It calculates the select time based on the dimensions of the part and machine settings. 5. The standard time (`Rstd!`) is calculated as a percentage of the select time. 6. Values in the `Elem!` array are populated with default or calculated values. 7. A message is added to a log for the part called "LASER". ### Sub Det_Salvagnini_Standard This subroutine appears incomplete, as it only includes the declaration of variables and does not contain any code. #### Purpose The purpose of this subroutine is to determine the Salvagnini standard time for a specific part. However, due to its incomplete nature, it cannot be executed or provide meaningful results. #### Chunk 23 **Detailed Markdown Description of VBA Code** ### Module Overview This VBA code module appears to be part of an Excel or Access application, utilizing database connections and recordsets to retrieve machine data. The code consists of two primary subroutines: `Det_Mult_Shear` and the main subroutine with no explicit name. ### Main Subroutine Description #### Purpose The main subroutine's purpose is to calculate various statistics for a given part number (`PN$`) using data retrieved from a database. #### Steps: 1. **Set Search Criteria**: The code sets the search criteria by concatenating the `PartNumber` field with a specific string value. 2. **Connect to Database and Open Recordset**: The code establishes a connection to a database and opens a dynamic recordset (`MachQSet`) from the "MachinesQ1" table. 3. **Find First Occurrence of Prime Machine**: The code finds the first occurrence of a prime machine in the recordset, extracting relevant fields such as `MachineName`, `Tool`, and `CycleTime`. 4. **Calculate Cycle Time Statistics**: The code calculates various statistics based on the retrieved data: * `Paperwork`: A constant value representing paperwork (0.06) * `pfd`: A constant value representing production factor demand (1.1) * `ctime!`: The cycle time * `SelectTime`: The select time calculated by adding `Paperwork` to the cycle time * `Mstd!`, `Rstd!`: Standard and rate statistics calculated based on `SelectTime` 5. **Populate Elements Array**: The code populates an `Elements` array with various statistics, including `ct`, `SelectTime`, `StandardParts`, and more. 6. **Add Element to Database**: The code calls a function `Elem_Add` to add the `PartNumber` (`PN$`) and labels "SALV" and "SALVAGNINI" to the database. ### Det_Mult_Shear Subroutine Description #### Purpose The `Det_Mult_Shear` subroutine calculates various statistics for multiple shear runtime, given specific parameters (`SHEAR!`, `TShear!`). #### Steps: 1. **Set Constants**: The code sets constants for `Paperwork`, `pfd`, and other values. 2. **Clear Elements Array**: The code calls a function `Elem_ClearArray` to clear the elements array. 3. **Determine Blanket Weight**: The code calculates the blanket weight based on the actual part height and width. 4. **Calculate Shear Statistics**: The code calculates various statistics for multiple shear runtime, including: * `SHEAR!`, `TShear!`: Total shear time * `Elem1` to `Elem6`: Individual elements in the elements array * `Blank_wt`, `Elems3` and `4`, `Elems5` and `6` 5. **Return Statistics**: The code returns the calculated statistics (`SHEAR!` and `TShear!`) #### Chunk 24 **Detailed Description of VBA Code** ### Section 1: Element Array Calculations The code starts by calculating various values for an element array (`Elem!`) using the following formulas: * `Elem!(1) = SHEAR + Paperwork`: Calculates the total select time. * `Elem!(2) = 1`: Specifies the number of parts. * `Elem!(3) = Elem!(1) / Elem!(2)`: Calculates the total minutes required. * `Elem!(4) = Elem!(3) * pfd`: Calculates the overhead (overhead factor). * `Elem!(5) = Elem!(4) / 60`: Calculates the standard hours. These calculations are performed for two different contexts: "CONT" and "T/S". The "MULTSHEAR" key is added to the part number (`PartN$`) in both cases using the `Elem_Add` function. ### Section 2: Sub Det_Pedestal_Grinder_Standard This subroutine calculates various parameters for a pedestal grinder standard based on input values: * `DIMENSION_1` and `DIMENSION_2`: Dimensions of the part * `Side%`: Side number (used to determine which machine to use) * `RunStd!`: Standard running flag * `Labor!`: Labor indicator The subroutine performs the following tasks: * Clears an element array (`Elem_ClearArray`) to ensure previous calculations are cleared. * Sets the current form's part number (`PartN$`) and calculates the calculation status caption. * Sets various constants: + `Paperwork` (1% overhead) + `PEDESTAL_GRINDER_MACHINE_TIME_PER_INCH` (time per inch for the machine) + `Pedestal_Grinder_Pfd` (overhead factor for pedestal grinder) * Determines labor settings based on the input value (`Labor!`): + If labor is 1, `noelem = 1`; otherwise, `noelem = 0` + Calculates blank weight and body movements. * Determines single-edge and multiple-edge handling coefficients based on dimension values: + The code uses a series of if-else statements to determine the correct coefficients. ### Notes The code appears to be part of an industrial automation or manufacturing system, possibly using Autodesk's AutoCAD and/or other software. The calculations and parameters seem to be related to the calculation of time, labor, and overhead for various machine operations. #### Chunk 25 **Detailed Description of VBA Code** ### Subroutine: `PEDESTAL_GRINDER_STANDARD` This subroutine calculates the labor hours, machine time, and standard time for a pedestal grinder operation. It takes into account various parameters such as edge deburring, part dimensions, and handling times. #### Conditional Calculations The subroutine uses a `Select Case` statement to determine the total inches deburred (`TOTAL_INCHES_DEBURRED`) based on the value of `Side%`. The corresponding values for `Number_Of_Edges_Deburred`, `typ$`, and other variables are then calculated accordingly. #### Labor Hours Calculation The labor hours (`Pedestal_Grinder_Labor`) are calculated by adding the handling time (`Pedestal_Grinder_Handling_Time`), machine time (`PEDESTAL_GRINDER_MACHINE_TIME`), and body movements (`Body_Movements`). The standard time (`Pedestal_Grinder_STD`) is then calculated as a percentage of the total labor hours. #### Data Writeback The subroutine writes back calculated values to various elements in an array (`Elem!`). * `Labor!`: Pedestal Grinder Labor * `RunStd!`: PEDESTAL_GRINDER_STD (Standard Time) * `Number_Of_Edges_Deburred`, `typ$`, `TOTAL_INCHES_DEBURRED`, and other variables are written back to their corresponding elements in the array. ### Subroutine: `DETECT_PRESSBRAKE_STANDARD` This subroutine retrieves data from a database table named "PressBrakes" based on user input. It takes into account various parameters such as warehouse codes, press brake types, and machine numbers. #### Database Retrieval The subroutine uses ADO (ActiveX Data Objects) to connect to the database and retrieve records from the "PressBrakes" table. The retrieved data includes: * `wc2`: Warehouse code * `wc3`, `wc4`: Machine numbers * `wc5`: Press brake type * `pressBrake`: Press brake number #### Conditional Logic The subroutine checks if a match is found in the database. If a match is found, it updates the user interface (`currform!`) with the retrieved values. ### Other Constants and Variables The code also defines several constants and variables, including: * `MULTIPLE_EDGE_HANDLING` and `SINGLE_EDGE_HANDLING`: handling times for multiple and single edges * `PARTN$`, `typ$`, `PEDESTAL_GRINDER_MACHINE_TIME_PER_INCH`, `Body_Movements`, `Paperwork`, `Pedestal_Grinder_Pfd`, `lb_per_sq_ft!`: various constants and variables used throughout the code. Overall, this VBA code is designed to automate tasks related to pedestal grinder operations, including calculating labor hours, machine time, and standard time. It also retrieves data from a database table for press brake operations. #### Chunk 26 **VBA Code Description** ======================== This VBA code is used to calculate and record various metrics for a process, likely in an assembly line or manufacturing context. The code consists of several sections that handle different scenarios based on the input value `Blank_wt`. ### Select Case Block The first section of the code uses a `Select Case` statement to determine the values of `elm5`, `elm7`, and `frq` based on the input value `Blank_wt`. The case values are: * `Blank_wt \u003c= 4`: assigns `elm5 = 0.048`, `elm7 = 0.032`, and `frq = 0` * `Blank_wt \u003c= 8`: assigns `elm5 = 0.071`, `elm7 = 0.036`, and `frq = 4` * `Blank_wt \u003c= 12`: assigns `elm5 = 0.085`, `elm7 = 0.041`, and `frq = 8` * `Blank_wt \u003c= 20`: assigns `elm5 = 0.095`, `elm7 = 0.045`, and `frq = 12` * Else: assigns `elm5 = 0.102`, `elm7 = 0.05`, and `frq = 16` These values are then used to calculate other metrics. ### Calculating Metrics The code calculates the following metrics: 1. `hits`: This is calculated as `hits - 1` based on the value of `frq`. 2. `Totaltime`: This is calculated by summing up `elm5`, `elm7`, `elm9`, and `elm11`. ### Recording Metrics to Workbook The code records the calculated metrics in a workbook using the `Elem!` array. The recorded values include: * `Paperwork` * `Totaltime` * `hits` * `PartN$` ### Creating Table Entries The code creates table entries for each part using the `Call Elem_Add` and `ds_add` functions. ### Variables and Constants Some variables and constants are used in this code: * `Blank_wt`: This is the input value that determines the values of `elm5`, `elm7`, and `frq`. * `hits`: This variable represents a count or number. * `Totaltime`: This variable represents the total time spent on an activity. * `pfd`: This constant is used to calculate `Totaltime`. Overall, this code appears to be part of a larger process that tracks and records various metrics for assembly line activities. #### Chunk 27 **Detailed Description of VBA Code: DET_PEM_Standard** =========================================================== ### Purpose and Parameters The `DET_PEM_Standard` subroutine is designed to calculate the total runtime for a standard part in a production environment. It takes six parameters: * `r!`: The run standard value. * `hits`: The number of presses performed. * `w2$, W3$, W4$`: Work centers (warehouse, work center 3, and work center 4). * `AM$`: Auto or Manual. ### Code Execution Here is a step-by-step breakdown of what the code does: 1. **Initialization** * It sets up variables for database connections (`PemTab` and `PemTabSet`) but does not execute any actions with these variables due to commented-out lines. 2. **Displaying Form Title and Clearing Arrays** * The form title is changed to "Determine PEM runtime." * An array-clearing function called `Elem_ClearArray` is executed. 3. **Querying Press Tab Set** * A query is made to retrieve data from a table named "PressTabSet" using the `PressBrake` value as a filter. * The results are assigned to variables `w2$, W3$, and W4$`, and `M$`. * If no matching records exist, the code sets these variables to their default values. 4. **Calculating Blank Weight** * A blank weight calculation is performed based on the part type (`AM$`). 5. **Select Case Statement for Blank Weight** * The `blank_wt` value is compared against different ranges, and corresponding values are assigned to variables `elm5`, `elm6`, and `frq`. * These values determine various elements in an array. 6. **Calculating Element Values** * Based on the calculated `blank_wt` and `hits` values, the following elements are filled: * `elem!(0)` to `elem!(5)`: Calculated based on `blank_wt`, `hits`, `frq`, and other variables. 7. **Calculating Total Time** * The total time is calculated using the `totaltime` variable, which includes the blank weight (`Paperwork`) and other elements. 8. **Updating Run Standard Value** * The updated run standard value (`r!`) is calculated as a percentage of the total time, multiplied by the paper factor (`pfd`) divided by 60. 9. **Adding Data to Database** * Finally, data related to the part (part number and type) are added to the database using `ds_add` and `Elem_Add`. ### Notes * The code makes extensive use of global variables and arrays, which may be a sign that it's intended for reuse or modification in a larger application. * Some parts of the code appear to be commented out or unused, indicating potential refactoring opportunities. Overall, this VBA code is designed to perform complex calculations for standard part processing in a production environment. Its structure and variable usage suggest that it may be part of a larger application. #### Chunk 28 **Detailed Description of VBA Code: Det_Shear_Standard** This VBA code is a sub procedure named `Det_Shear_Standard` that calculates and determines various statistics for a shear standard. The code appears to be part of an industrial manufacturing process, specifically for cutting and processing metal sheets. ### Initialization The code begins by setting the caption of a control (`currform!txtCalcStat`) to "Determine shear runtimes." It then calls `DoEvents` to ensure that any pending events are processed. ### Time Setup The code defines a series of constants representing time values for different stages of the manufacturing process, including: * **PROGRAM_SETUP_TIME**: 0.166 seconds * **OBTAIN_AND_STARTUP_VACCULIFT**: 0.099 seconds * **WALK_TO_AND_FROM_MATERIAL_Q1**, **Q2**, **Q3**, and **Q4**: 0.167, 0.32, 0.5, and 0.667 seconds, respectively * **OBTAIN_SHEET**: 0.18 seconds * **INSERT_TO_WRKHLDR_AND_STOP**: 0.083 seconds * **ACTIVATE_FOOT_PEDAL** and **ACTIVATE_START_BUTTON**: 0.015 seconds each * **RateR**, **PULLMAX_FIXED_FEEDRATE**, **NIAGRA_FIXED_FEEDRATE**, **PULLMAX_LAST_PART_EJECT**, **NIAGRA_LAST_PART_EJECT**, **PULLMAX_SQUARE_CUT**, **NIAGRA_SQUARE_CUT**: 0.0024, 0.045, 0.028, 0.05, 0.024, 0.045, and 0.028 seconds, respectively * **REMOVE_SCRAP_AND_ASIDE**: 0.039 seconds * **PICK_UP_AND_MOVE_TO_SHEAR**: 0.028 seconds * **MOVE_AND_POSITION_PEICE**: 0.024 seconds * **REMOVE_REPOSITION_AND_REASSEMBLE**: 0.029 seconds * **Paperwork**: 0.4 seconds * **Shear_Pfd**: 1.15 seconds * **LOT_SIZE_RED_OFFALL**: 0.8 + 0.05 (80% Lot size reduction and 5% offall) ### Part Number and Sheet Dimensions The code retrieves the `PartNumber` from a form control (`currform`) and calculates the weight of a blank sheet based on the first cut dimensions. * **PartN$**: The retrieved part number. * **Blank_wt**: The calculated weight of a blank sheet (FirstCut * Sheet_Width / 144 * lb_per_sq_ft!). ### Spin Blank Calculations The code determines whether to perform spin blanks for the first and second cuts based on specific conditions. * **SPIN_BLANK_ON_FIRSTCUT** and **SPIN_BLANK_ON_SECCUT**: Initially set to 0. * If (SHEAR_1_OFFALL \u003c 2) And (Blocks_Per_Sheet \u003e 1), then SPIN_BLANK_ON_FIRSTCUT = REMOVE_REPOSITION_AND_REASSEMBLE. * If (SHEAR_2_OFFALL \u003c 2) And (Blanks_Per_Block \u003e 1), then SPIN_BLANK_ON_SECCUT = REMOVE_REPOSITION_AND_REASSEMBLE. ### Standard Cut Calculations The code calculates the standard cut times for the first and second cuts based on various constants and user input values, such as `ExtraShear%`, `Multi$`. * **First_Cut_Std**: The calculated standard time for the first cut. * If ExtraShear%, then First_Cut_Std = (RateR * SecondCut + PULLMAX_FIXED_FEEDRATE) \* Blocks_Per_Sheet. Otherwise, First_Cut_Std = (RateR * FirstCut + PULLMAX_FIXED_FEEDRATE) \* Blocks_Per_Sheet. The calculated standard times are added up and adjusted based on various constants and process conditions. ### Final Calculations The code calculates the final standard time for each cut by applying the `Shear_Pfd` value and a 60-minute factor to the individual standard times. These calculations are then used in the rest of the program. The final result is likely used to determine the actual runtime or processing time for the shear standard. #### Chunk 29 **Calculation of Standard Cut Times for Shear Operations** =========================================================== This VBA code calculates the standard cut times for shear operations, taking into account various factors such as cut type, material feed rates, and labor costs. ### Overview The code consists of two main sections: one for calculating the standard cut time for single cuts (`CalcFirstCutStuff`) and another for multiple cuts (`CalcMultipleCutStuff`). The standard cut times are stored in variables `Second_Cut_Std` and `Multiple_Cut_Std`, respectively. ### Single Cut Calculation The code begins by initializing the `Second_Cut_Std` variable to 0. It then calls a series of subroutine references, which perform various tasks such as: * Picking up and moving to the shear * Positioning a piece on the shear * Spinning blank on cut * Paperwork handling The `GoSub CalcSecondCutStuff` statement jumps to a subroutine that calculates the standard cut time for single cuts. ```markdown Second_Cut_Std = Second_Cut_Std + PICK_UP_AND_MOVE_TO_SHEAR Second_Cut_Std = Second_Cut_Std + MOVE_AND_POSITION_PEICE Second_Cut_Std = Second_Cut_Std + SPIN_BLANK_ON_SECCUT ``` The `GoSub CalcSecondCutStuff` statement executes the following code: ```markdown Second_Cut_Std = Second_Cut_Std / Blanks_Per_Block Second_Cut_Std = Second_Cut_Std * Shear_Pfd Second_Cut_Std = Second_Cut_Std / 60 ``` These calculations adjust the standard cut time based on the blanks per block, shear pressure factor, and other factors. ### Multiple Cut Calculation The code then checks if `ExtraShear%` is True. If it is, it sets `SPIN_BLANK_ON_SECCUT` to 0 and adjusts other variables accordingly. ```markdown Case "MULTIPLE" If ExtraShear% Then SPIN_BLANK_ON_SECCUT = 0 ... ``` The code then calculates the standard cut time for multiple cuts (`Multiple_Cut_Std`). It executes a similar series of subroutine references as in the single cut calculation. ```markdown Multiple_Cut_Labor = RateR * Bottom_Trim_Cut + NIAGRA_FIXED_FEEDRATE ... Multiple_Cut_Std = Multiple_Cut_Labor ``` The code then adjusts `Multiple_Cut_Std` based on parts per blank and shear pressure factor. ### Labor Cost Calculation The code calculates labor costs for multiple cuts (`Multiple_Cut_Labor`). It considers factors such as: * Top trim cut time * Bottom trim cut time * Material feed rates * Labor cost multipliers (e.g., `RateR`, `NIAGRA_FIXED_FEEDRATE`) ```markdown Number_Of_Top_Cuts = 0 If TOP_TRIM_CUT \u003e 0 Then Number_Of_Top_Cuts = 1 Multiple_Cut_Labor = RateR * Bottom_Trim_Cut + NIAGRA_FIXED_FEEDRATE ... ``` The code calculates the standard cut time for multiple cuts (`Multiple_Cut_Std`) by adjusting `Multiple_Cut_Labor` based on parts per blank and shear pressure factor. ### Conclusion This VBA code provides a structured approach to calculating standard cut times for shear operations, taking into account various factors such as material feed rates, labor costs, and other operational considerations. #### Chunk 30 **VBA Code Description** ========================== This VBA code is designed to populate an array of elements with various settings and values related to a cutting process. The code is divided into three main sections: `CalcFirstCutStuff`, `CalcSecondCutStuff`, and `CalcMultipleCutStuff`. ### CalcFirstCutStuff This section calculates the settings for the first cut in a cutting process. * It clears any existing data in an array. * Sets various element values, including: * Paperwork (element 0) * Total select time (elements 1 and 2) * Parts per sheet (element 2) * Total minutes for first cut (element 3) * Overhead for first cut (element 4) * Standard hours for first cut (element 5) * Lot size reduction and offall percentage (element 46) * Calls the `Elem_Add` function to add a new element to the array with the specified values. * Returns from the subroutine. ### CalcSecondCutStuff This section calculates the settings for the second cut in a cutting process, which is only executed if the `ExtraShear%` variable is true. * Clears any existing data in an array. * Sets various element values, including: * Paperwork (element 0) * Total select time (elements 1 and 2) * Parts per block (elements 23 and 25) * Blanks per block (element 24) * If `ExtraShear%` is true, sets the part value to `FirstCut` and the blanks value to `(RateR * FirstCut + NIAGRA_FIXED_FEEDRATE) * Blanks_Per_Block`. * Otherwise, sets the part value to `SecondCut!` (a variable that needs to be defined elsewhere in the code). * Calls the `Elem_Add` function to add a new element to the array with the specified values. * Returns from the subroutine. ### CalcMultipleCutStuff This section calculates the settings for multiple cuts in a cutting process, which includes top trim cuts and bottom trim cuts. * Clears any existing data in an array. * Sets various element values, including: * Paperwork (element 0) * Total select time (elements 1 and 2) * Parts per block (elements 23 to 28) * Calls the `Elem_Add` function to add a new element to the array with the specified values. * Returns from the subroutine. Overall, this code appears to be part of a larger system for managing cutting processes and calculating settings based on various inputs and variables. #### Chunk 31 *Failed to generate documentation with Ollama* #### Chunk 32 *Failed to generate documentation with Ollama* #### Chunk 33 *Failed to generate documentation with Ollama* #### Chunk 34 **Detailed Description of VBA Code** ### Module Overview This VBA code module appears to be part of a larger application that interacts with an Access database. It defines three subroutines: `ELEM_ClearAllRecs`, `ELEM_ClearArray` is incomplete and seems out of context, and the main subroutine which clears and populates data records in a specified sheet. ### Main Subroutine ```markdown Sub Main() ' Set database connection and recordset object Set DataShDB = DBEngine.Workspaces(0).Databases(0) Set DataShSet = DataShDB.OpenRecordset("DataSheetQ1", DB_OPEN_DYNASET) ' Check if there are no data sheets to process If NoDataSheets% = 0 Then Exit Sub End If ' Add a new record to the database DataShSet.AddNew ' Populate recordset fields with provided values DataShSet!PartNumber = PartN$ DataShSet!Operation = Oper$ DataShSet!SheetType = ShType$ DataShSet!Generated = True ' Populate various field groups (Elem1 to Elem12) with data from an 'Elem' array For i = 0 To 11 DataShSet!"Elem" \u0026 (i + 1) \u0026 "A" = Elem!(i * 2) DataShSet!"Elem" \u0026 (i + 1) \u0026 "V" \u0026 Chr(65 + i) = Elem!(i * 2 + 1) Next i ' Update the recordset to ensure all fields are set DataShSet.Update End Sub ``` This subroutine: * Checks if there are no data sheets (`NoDataSheets`) and exits early if so. * Opens a new database connection and sets up a recordset for "DataSheetQ1" using dynamic access mode. * Adds a new record to the recordset. * Sets various fields from `PartN$, Oper$, ShType$`, and `Elem` arrays, which are assumed to be defined elsewhere in the application. ### Subroutine: ELEM_ClearAllRecs(PartN$) ```markdown Sub Elem_ClearAllRecs(PartN$) ' Check if output data is enabled before processing If Not (OutPutData%) Then Exit Sub End If ' Define search criteria for the recordset Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set up database connection and recordset object Set DataShDB = DBEngine.Workspaces(0).Databases(0) Set DataShSet = DataShDB.OpenRecordset("DataSheetQ1", DB_OPEN_DYNASET) ' Find the first occurrence of the search criteria DataShSet.FindFirst Criteria$ ' Loop until no matching records are found, deleting each record as it's found Do Until DataShSet.NoMatch s$ = DataShSet!PartNumber If DataShSet!Generated = True Then ' Delete the record if it has a generated flag set to true DataShSet.Delete End If DataShSet.FindNext Criteria$ Loop ' Update the recordset after clearing records DataShSet.Update End Sub ``` This subroutine: * Checks if output data is enabled before processing and exits early if not. * Defines a search criteria for finding records in "DataSheetQ1" based on `PartN$`. * Sets up a database connection and recordset object. * Finds the first occurrence of the search criteria using `FindFirst`, then enters a loop where it finds subsequent occurrences (`FindNext`) and deletes each matching record if its generated flag is set to true. ### Subroutine: ELEM_ClearArray ```markdown ' If Not (NoDataSheets%) Then ``` This subroutine appears incomplete as it does not include the code necessary for clearing data from an array. The `If` statement seems out of context, as there's no indication that this subroutine is intended to be used without first determining if data sheets exist. ### Notes and Recommendations * Error handling: Consider adding try-catch blocks or checks for potential errors in accessing the database connection, opening recordsets, and performing operations. * Code organization: Some subroutines can be reorganized for better readability, such as extracting common logic into reusable functions or procedures. * Code security: Be cautious when concatenating strings using `+` operator to prevent potential SQL injection attacks. Consider using parameterized queries instead. * Performance optimization: For large datasets, consider implementing pagination, caching, or more efficient data retrieval strategies to improve performance. #### Chunk 35 Here is a detailed Markdown description of the provided VBA code: **Elem Initialization and Cleanup** ```markdown For i = 0 To 53 Elem!(i) = 0 DoEvents Next ' endif End Sub ``` This code initializes an array `Elem` by setting all its elements to 0. The loop iterates from 0 to 53, and after each iteration, it calls the `DoEvents` method to update the user interface. This ensures that any pending events are processed before moving on to the next element. **Elems_Del Sub** ```markdown Sub Elem_Del() ' ... End Sub ``` This sub appears to be responsible for deleting records from a database based on certain criteria. However, without more context or information about the `DataShSet` and `DBEngine`, it is difficult to provide further details. **ErrorMessages Sub** ```markdown Sub ErrorMessages() If currform![CalculationStatus] = 0 Then currform!TextCalcErr.Visible = False Else currform!TextCalcErr.Visible = True Select Case currform![CalculationStatus] ' ... End Select End If End Sub ``` This sub checks the `CalculationStatus` value of a form and displays an error message in a text control (`TextCalcErr`) if it is not 0. The error message is set based on the value of `CalculationStatus`, which appears to be a combination of numerical values representing different types of errors. **Find_By_MakeNumber Sub** ```markdown Sub Find_By_MakeNumber() PN$ = currform!PartNumber DocName = PrimaryScreen$ DoCmd.OpenForm DocName, , , LinkCriteria DoCmd.GoToControl "PartName" DoCmd.GoToControl "PhantomNumber" DoCmd.FindRecord PN$, A_ANYWHERE, False, A_DOWN, , , True End Sub ``` This sub searches for a record in a database based on the `PartNumber` value from a form. It opens a specified form (`PrimaryScreen$`) and navigates to two specific controls ("PartName" and "PhantomNumber") before searching for the record using the `FindRecord` method with the `ANYWHERE` criteria. In summary, these three subroutines appear to be responsible for: 1. Initializing an array and updating the user interface. 2. Deleting records from a database based on certain criteria (though this is not fully implemented). 3. Displaying error messages in response to calculation errors or other conditions. 4. Searching for records in a database based on a specific value from a form. Without more context or information about the application, it is difficult to provide further details or insights into these subroutines. #### Chunk 36 Here is a detailed Markdown description of the VBA code: **Main Menu Navigation** ------------------------ The first line of code navigates to the `A_FORMBAR` menu, which opens the form bar menu. ### Sub Find_By_PartNumber() * This subroutine finds a record in the database by searching for a specific part number. * It sets the current form's `PartNumber` field (`PN$`) and then opens the specified form using `DoCmd.OpenForm`. * The cursor is positioned at the "PartName" control, and then the search criteria are set to find all records with the specified part number (`A_ANYWHERE`). * After finding a match, it sets the current form's controls to point to the correct record. * It also navigates to the `A_EDITMENU` menu and selects option 9 (presumably "Edit"). ### Sub GOTOPARTNUMBER(PN$, PScreen$) * This subroutine opens a specified form and navigates to the part number field. * It sets the current form's name (`PScreen$`) and then opens the specified form using `DoCmd.OpenForm`. * The cursor is positioned at the "PartNumber" control, and then it searches for a record with the specified part number (`A_ANYWHERE`). ### Function FormitI$(A%, x$) * This function formats the specified value as an integer. * It takes two parameters: `A%` (the value to format) and `x$` (the format specifier). * The formatted value is returned. ### Function FormitS$(A!, x$) * This function formats the specified value as a string. * It takes two parameters: `A!` (the value to format) and `x$` (the format specifier). * The formatted value is returned. **Grain Direction** ------------------ ### Sub GrainFromRec() * This subroutine sets the grain direction based on the selected option in the form. * It gets the current grain direction from the form (`currform!GrainDir`) and then checks if it's not null or an empty string. * If it is, it sets the grain direction to "No Grain Direction" and sets `GrDirOpt` to 3. **History** --------- ### Sub HistoryR() * This subroutine updates the issue number, date, reason, and history fields in the form. * It checks if any of these fields are null or empty and then updates them accordingly. * The issue number is incremented by 1, and the current date is set as the new issue date. * The reason field is updated with a formatted string containing the reason and date. **String Manipulation** --------------------- ### Function instrl(A$, b$) * This function finds the last occurrence of a substring (`b$`) in a string (`A$`). * It returns the starting position of the found substring. ### Function itsaNull$(variableField) * This function checks if a variable field is null or empty and returns an empty string if so. * Otherwise, it returns the original value. ### Function ItsAZero!(variableField) * This function checks if a variable field is null or zero and returns zero if so. * Otherwise, it returns the original value. ### Function lpad$(A$, l) * This function pads a string with spaces to a specified length (`l`). **Make Processes** ----------------- ### Sub MakeProcesses() * This subroutine prepares for making processes by setting up various database objects and recordsets. * It sets the caption of a text box control to "Entering Make Process" and then waits for events using `DoEvents`. * The part number and warehouse are retrieved from the form, and search criteria are set. #### Chunk 37 **VBA Code: Opening and Processing Machine Data** This VBA code is used to open and process data from various databases in an Access application. The code appears to be part of a larger program that calculates machine performance metrics. ### Section 1: Opening Databases and Recordsets The code begins by opening several databases and recordsets using the `DBEngine` object: ```markdown - **AddnlQDB**: Opens the "AddnlQ1" database and creates a dynamic dataset. - **AddnlSet**: Creates a dynamic dataset from the "AddnlPROC" table in the same database. - **PressBrkDB**, **PemPressDB**, and **PunchPressDB**: Open other databases and create dynamic datasets. The `DoEvents` statement is used to process any pending events before proceeding with the code. ``` ### Section 2: Processing AddnlQ Data The code then processes data from the "AddnlQ1" database: ```markdown - Sets up a loop to find all records in the database. - For each record, it checks if the `Generated` flag is set. If so, it deletes the record. - If not, it checks specific conditions based on the `wc2` field value: - If `wc2` equals "345" or "347", sets `CalculationStatus` to 18 and calls an error message function. - Otherwise, performs further checks for specific warehouse codes. After processing each record, the code loops back to find the next record using the `FindNext` method. Finally, it clears a data sheet requirements array and sets up variables for machine data processing. ``` ### Section 3: Processing Machine Data The code then processes data from two databases related to machines: ```markdown - **MachQDB**: Opens the "MachinesQ1" database and creates a dynamic dataset. - **MachNQDB**: Opens the "MachineNames" table in another database and creates a dynamic dataset with an index set on the `PrimaryKey` field. The code loops through the records in both datasets, checking for specific conditions: - If a record has a `Prime` flag set to `True`, it checks if the machine tool is not equal to "SHR". If so, it sets up an error message function. - After processing all records, it clears another data sheet requirements array and sets variables for further processing. Note that the code appears to be incomplete, as it does not provide details on how the `ErrorMessages` function is used or what additional logic is required. ``` In summary, this VBA code opens and processes data from various databases in an Access application, performing calculations and error checks along the way. However, the code is incomplete, and further development is needed to fully understand its functionality and purpose. #### Chunk 38 **VBA Code Description** ========================== This VBA code is a part of an Excel spreadsheet and appears to be controlling the operation of a CNC machine. It processes user input, performs calculations, and generates data for various operations such as shearing, punching, and deburring. ### Variable Initialization and Setup The code initializes several variables: * `PMachine$`, `PWC1$`, and `PCTime!` store the machine name, tool name, and cycle time, respectively. * `MachQSet.FindNext Criteria$` is used to find the next occurrence of a value in a list or table. * `DoEvents` pauses the execution of the code to allow other Excel events to occur. ### Validation and Error Handling The code performs several checks: * If the machine name is empty, it sets the calculation status to 15 and calls the `ErrorMessages` subroutine. * If the punch press option is enabled but not set to 7, it sets the calculation status to 17 and calls the `ErrorMessages` subroutine. * If the "NO CNC" or "BLANK" options are selected, it calls the `Det_CNC_Highest_Runtime` function. ### Process Selection The code uses a `Select Case` statement to determine which process to execute based on the user input (`Multi$`): * For single-process options (e.g., SHEAR1), it calls the corresponding subroutine. * For multiple-process options (e.g., SHEAR2), it checks if there are extra shear operations and calls the corresponding subroutine accordingly. ### Additional Process Selection The code also includes additional process selection logic for specific machine types: * LASER, LASER/SHEAR, SLUG: If the sheet dimensions are not correct, it calls the `Shear1` subroutine. * SALVAGNINI: It simply calls the `CNCOp` subroutine. ### Output and Refresh The code generates output data based on user input: * If the `OutPutData%` variable is true, it refreshes the current form, renames numbers, and calls the `ErrorMessages` subroutine. * If there are no data sheets, it deletes elements using the `Elem_Del` function. ### AddAP Subroutine The code includes an `AddAP` subroutine that adds new records to a table using user input parameters: * It takes five parameters: `OpCode%`, `PartN$`, `Descr$`, and four other variables (`wc1$-wc4$`). ### CNCOp Subroutine The code includes a `CNCOp` subroutine that handles multi-process options: * It uses another `Select Case` statement to determine which process to execute based on the user input. **Note**: The code is not fully readable due to the absence of comments and variable descriptions. A more detailed explanation would require additional context or documentation about the specific Excel spreadsheet, CNC machine, and operations being performed. #### Chunk 39 *Failed to generate documentation with Ollama* #### Chunk 40 *Failed to generate documentation with Ollama* #### Chunk 41 *Failed to generate documentation with Ollama* #### Chunk 42 **VBA Code Description** ==================================== This VBA code appears to be part of a deburring process in a manufacturing or production environment. It determines the type of deburr method to use based on various factors, such as machine type, cell type, and labor requirements. ### Variable Initialization The code initializes several variables: * `completedeburr%`: an integer variable that stores the completion status of the deburring process (set to 2 if outside deburring is required). * `Celltype$`: a string variable that stores the type of cell being deburred, converted to uppercase. * `ctime!` and `Rstd!`: integer variables used as counters. * `PMachine$`, `Multi$`, `Mt$, `BadTs%`, `Actual_PartHeight`, and `Actual_PartWidth`: string variables that store machine-specific information. ### Machine Type Detection The code checks the first three characters of the `PMachine$` variable to determine the machine type. If it matches "L-2", specific values are assigned to other variables: * `wc2$`: a string variable set to either "330" or "312", depending on the machine type. * `wc1$`, `wc3$`, and `wc4$`: string variables initialized with default values. ### Deburring Method Selection The code uses an `If-Else` statement to determine the deburring method based on the `Celltype$` variable: * For "HAND DEBURR", it calls a subroutine `Det_HandDeburr` and assigns specific descriptions. * For "TIME SAVER", if the machine is specified as "TIMESAVER" or has a certain ID, it calls a different subroutine `Det_TimeSaver_Labor`. Otherwise, it calls another subroutine `Det_Pedestal_Grinder_Standard`. ### Additional Logic The code includes additional logic to handle specific cases: * If `completedeburr%` is 1, it uses the top trim cut value. * For certain machine types, it assigns specific values to `wc2$`. * It also calls `ds_add` subroutines to add data to a database or log. Overall, this VBA code appears to be part of a complex deburring process that requires careful consideration of various factors to determine the most efficient and effective method for deburring. #### Chunk 43 *Failed to generate documentation with Ollama* #### Chunk 44 *Failed to generate documentation with Ollama* #### Chunk 45 *Failed to generate documentation with Ollama* #### Chunk 46 **VBA Code Description** This VBA code appears to be a part of a larger program for managing and deburring parts. It uses various variables and constants to determine the type of operation required based on machine type, deburbing method, and other factors. **Section 1: Primary Machine Name Extraction** ```markdown ' Obtain the Primary Machine name. PrimeType$ = Left$(PMachine$, 3) ``` This section extracts the first three characters of the `PMachine` variable to obtain the primary machine name. **Section 2: Single Part Deciphering** ```markdown If (Multi$ = "SINGLE") Or (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then ... End If ``` This section checks if the `Multi` variable is set to a specific value, indicating that it's a single part operation. Based on this value, it sets various deburring flags and options. **Section 3: Multiple and Laser Part Deciphering** ```markdown Else ... End If ``` If the `Multi` variable is not set to a single part operation, this section checks if the primary machine name contains specific values. Based on this value, it sets additional deburring flags and options. **Section 4: Exclude All Parts Timesaver Deburrrs** ```markdown If Mt$ = "NO TIMESAVER" Then dbtype!(2, 0) = 0 ... End If ``` This section checks if the `Mt` variable is set to "NO TIMESAVER". If so, it sets various deburring flags to zero. **Section 5: Exclude Invalid Trim Cuts for Shear Operations** ```markdown If (InStr(MachinesWithShears$, PrimeType$) \u003c\u003e 0) And (Multi$ = "MULTIPLE") Then ... End If ``` This section checks if the primary machine name contains specific values and if the `Multi` variable is set to "MULTIPLE". If so, it sets flags related to invalid trim cuts for shear operations. **Section 6: Exclude Operations that Manual Selection has Indicated** ```markdown Select Case Celltype$ ... End Select ``` This section uses a `SELECT CASE` statement to check the value of the `Celltype$` variable. Based on this value, it sets various deburring flags and options. **Variables and Constants Used** * `Multi`: a string variable indicating the type of operation (single part or multiple parts). * `PMachine`: a string variable containing the primary machine name. * `MachinesWithShears$:`, `TypeDeburr$`, `TopTrimCut$`: constants or variables used to determine specific deburring options. * `Bottom_Trim_Cut!`: a constant or variable indicating the bottom trim cut value. * `Celltype$`: a string variable containing the cell type (hand deburr, pedestal, etc.). * `dbtype!(...)$: an array of constants or variables used to store deburring flags and options. Note that some of the code is commented out, which may indicate areas where the code has not been fully implemented or tested. #### Chunk 47 **Detailed Description of the Provided VBA Code** The provided VBA code is composed of multiple subroutines, each with its own specific purpose. Here's a detailed explanation of what each section does: ### Setting Default Database Types ```markdown dbtype!(1, 0) = 0 dbtype!(3, 0) = 0 dbtype!(4, 0) = 0 ... dbtype!(13, 0) = 0 ``` This section sets default values for database types. `dbtype!` appears to be a global variable or array that stores the database type for each dimension (1, 3, 4, etc.). The `dbtype!` value is set to 0, indicating that these dimensions are not being used. ### Conditional Statements and Function Calls ```markdown Case Else End Select Call Det_Deburr_Run_Times(CNCTime!, DbSel%, completedeburr%) ' SecondShear = True ' If (TOP_TRIM_CUT! = 0 Or TOP_TRIM_CUT! = 2 Or TOP_TRIM_CUT! = 2.25) And (Bottom_TRIM_CUT! = 2 Or Bottom_TRIM_CUT! = 2.25) Then ' SecondShear = False ' End If 'If ((DbSel% \u003e 2) And (DbSel% \u003c 11)) Or (DbSel% = 13) Or (DbSel% = 14) Or (DbSel% = 16) Then Call CNC_Verbage(DbSel%, vb$) Return ``` This section contains a conditional statement that appears to be part of a larger program. The code calls the `Det_Deburr_Run_Times` function, passing in three parameters: `CNCTime!`, `DbSel%`, and `completedeburr%`. The function seems to be related to deburring processing. The commented-out section suggests that there is additional logic for handling top and bottom trim cuts. If these conditions are met, the `SecondShear` variable would be set to False. ### CNC Verbage Function Call ```markdown Call CNC_Verbage(DbSel%, vb$) ``` This line calls a function named `CNC_Verbage`, passing in two parameters: `DbSel%` and an unnamed string literal `vb$`. The purpose of this function is unclear without more context. ### NewGrain Subroutine ```markdown Sub NewGrain() If currform!GrDirOpt = 1 Then currform!GrainDir = "Along First Dimension" End If ... ``` This subroutine appears to be related to grain direction. It checks the value of `currform!GrDirOpt` and sets the `currform!GrainDir` property accordingly. The values of `1`, `2`, and `3` are assigned to specific string literals, which may represent different grain directions (e.g., "Along First Dimension", "Along Second Dimension", or "No Grain Direction"). ### OpenMainFiles Subroutine ```markdown Sub OpenMainFiles() 'AddnlQ1 ... ``` This subroutine is responsible for opening various databases and recordsets. The code appears to be a series of comments, each starting with `Addnl` followed by the name of the database or recordset being opened (e.g., "AddnlQ1", "StAddnlQDB", etc.). The actual code that opens these databases is commented out, suggesting that this subroutine may not be currently in use. ### Data Sheet Opening ```markdown DataSheet ' currform!txtCalcStat.caption = "Open - Opening StDataShDB": DoEvents ' Set StDataShDB = DBEngine.Workspaces(0).Databases(0) ' Set StDataShSet = StDataShDB.OpenRecordset("DataSheetQ1", DB_OPEN_DynaSet) ``` This section appears to be related to opening a data sheet database and recordset. The code sets the caption of `currform!txtCalcStat` and then opens the "DataSheetQ1" recordset from the `StDataShDB` database using the `DB_OPEN_DynaSet` option. ### Process Opening ```markdown Process ' currform!txtCalcStat.caption = "Open - Opening StPressTab": DoEvents ' Set StPressTab = DBEngine.Workspaces(0).Databases(0) ' Set StPressTabSet = StPressTab.OpenRecordset("PressBrakes", DB_OPEN_TABLE) ``` This section appears to be related to opening a process database and recordset. The code sets the caption of `currform!txtCalcStat` and then opens the "PressBrakes" recordset from the `StPressTab` database using the `DB_OPEN_TABLE` option. ### Data Sheet Opening (Alternative) ```markdown DataSheet ' currform!txtCalcStat.caption = "Open - Opening StDataShDB": DoEvents ' Set StDataShDB = DBEngine.Workspaces(0).Databases(0) ' Set StDataShSet = StDataShDB.OpenRecordset("DataSheetQ1", DB_OPEN_DynaSet) ``` This section is similar to the previous one, but with a different database and recordset being opened. ### Data Sheet Opening (Final) ```markdown DataSheet ' currform!txtCalcStat.caption = "Open - Opening StDataShDB": DoEvents ' Set StDataShDB = DBEngine.Workspaces(0).Databases(0) ' Set StDataShSet = StDataShDB.OpenRecordset("DataSheetQ1", DB_OPEN_DynaSet) ``` This section is identical to the previous one, suggesting that it may be a duplicate or alternative implementation. Note: The code provided appears to be incomplete and may require additional context to fully understand its purpose and functionality. #### Chunk 48 **VBA Code Description** ======================== ### PressBrake Functionality This VBA code appears to be part of an Access database application. It provides functionality for opening and interacting with three different recordsets: `PressBrakeQ1`, `PunchPress`, and `PressBrakeOps`. #### Section 1: Opening Recordsets The code begins by defining a sub routine that opens the recordsets: ```markdown ''PressBrake ' currform!txtCalcStat.caption = "Open - Opening StPressBrk": DoEvents ' Set StPressBrk = DBEngine.Workspaces(0).Databases(0) ' Set StPressBrkSet = StPressBrk.OpenRecordset("PressBrakeQ1", DB_OPEN_DynaSet) ''PunchPress ' currform!txtCalcStat.caption = "Open - Opening StPunchPress": DoEvents ' Set StPunchPress = DBEngine.Workspaces(0).Databases(0) ' Set StPunchPressSet = StPunchPress.OpenRecordset("PunchPress", DB_OPEN_Table) '''PressBrakeOps ' currform!txtCalcStat.caption = "Open - Opening StPressOps": DoEvents ' Set StPressOps = DBEngine.Workspaces(0).Databases(0) ' Set StPressOpsSet = StPressOps.OpenRecordset("PressBrakeOps", DB_OPEN_Table) ``` Each section opens a recordset using the `DBEngine` object, which is an interface to a database engine. The specific recordsets opened are: * `PressBrakeQ1` * `PunchPress` * `PressBrakeOps` The recordsets are opened in two different modes: * `DB_OPEN_DynaSet`: Opens the recordset as a dynamic set, which allows for dynamic data manipulation. * `DB_OPEN_Table`: Opens the recordset as a table, which is used by the Punch Press functionality. #### Section 2: PBFormView Sub Routine This sub routine appears to be responsible for displaying the part number and associated machine information on the form. ```markdown Sub PBFormView() PartN$ = currform![PartNumber] Set MachQDB = DBEngine.Workspaces(0).Databases(0) Set MachQSet = MachQDB.OpenRecordset("MachinesQ1", DB_OPEN_DYNASET) ' Create dynaset. Criteria$ = "PartNumber = '" + PartN$ + "'" ' Set search criteria. PMachine$ = "" MachQSet.FindFirst Criteria$ ' Find first occurrence. FL$ = Trim$(UCase$(itsaNull(currform!PressBrake))) currform!txtPrime = "" PMachine$ = "" Do Until MachQSet.NoMatch ' Loop until no matching records. If MachQSet!Prime = True Then PMachine$ = MachQSet!MachineName Exit Do End If MachQSet.FindNext Criteria$ ' Find next occurrence. DoEvents Loop currform!txtPrime = PMachine$ currform!PressBrake.Requery Select Case FL$ Case "1" currform!PressBrakeSubForm.Visible = False Case Else currform!PressBrakeSubForm.Visible = True End Select ``` Here's a step-by-step explanation of the code: * Retrieves the part number from the form. * Opens the `MachinesQ1` recordset as a dynamic set using `DB_OPEN_DYNASET`. * Sets the search criteria to find records with the specified part number. * Finds the first occurrence in the recordset that matches the part number and stores its machine name in `PMachine$`. * Loops through the remaining records until no more matching records are found. * Updates the form fields with the machine information. * Requeries the `PressBrake` recordset using the updated filter. #### Section 3: Opps Function This function takes an opcode as input and returns a string slice of length 4 from the right end of the opcode: ```markdown Function Opps$(OpCode%) Opps$ = Right$(" " + Str$(OpCode%), 4) End Function ``` This function appears to be used in other parts of the codebase, but its purpose is not immediately clear without more context. ### Conclusion In summary, this VBA code provides functionality for opening and interacting with three recordsets: `PressBrakeQ1`, `PunchPress`, and `PressBrakeOps`. It also contains a sub routine for displaying part number and machine information on the form. #### Chunk 49 **VBA Code Documentation** ========================== ### PemPressView Subroutine #### Purpose: This subroutine controls the visibility of form elements based on a value stored in `FL$`. #### Description: * Checks the value of `FL$` and sets the corresponding values for: * `PemPress Ops subform`: Sets its visibility to `True` if `FL$` is `-1`, otherwise sets it to `False`. * `lblPemBefore` and `PemBefore`: Also toggles their visibility accordingly. #### Code Snippet: ```markdown Sub PemPressView() FL$ = Trim$(UCase$(currform!Pems)) Select Case FL$ Case "-1" currform![PemPress Ops subform].Visible = True currform![lblPemBefore].Visible = True currform![PemBefore].Visible = True Case Else currform![PemPress Ops subform].Visible = False currform![lblPemBefore].Visible = False currform![PemBefore].Visible = False End Select End Sub ``` ### PunchPressOptions Subroutine #### Purpose: This subroutine manages the visibility and settings of form elements related to punch press operations. #### Description: * Checks the current values of various form fields and updates their visibility accordingly. * Updates labels, input boxes, and checkboxes based on the selected cutting type and punch die options. * Ensures that the `PunchDie` field is set to a valid value (`!NONE!`) if it's empty or null. #### Code Snippet: ```markdown Sub PunchPressOptions() If IsNull(currform!PunchDie) Then currform!PunchDie = "!NONE!" If Trim$(currform!PunchDie) = "" Then currform!PunchDie = "!NONE!" If (currform!CutType = "Multiple") Or (currform!CutType = "Laser") Or (currform!CutType = "Salvagnini") Or (currform!CutType = "Laser/Shear") Or (currform!CutType = "Slug") Then currform!PunchPressOption.Visible = False currform!PunchDie.Visible = False currform!PunchCount.Visible = False currform!PunchStd.Visible = False Else ... ``` ### PurgeCNCs Subroutine #### Purpose: This subroutine removes duplicate CNC records from a database. #### Description: * Retrieves machine names and machines datasets from the database. * Opens the "Process" recordset in the main database. * Iterates through the `PartNumber` index in the "Machines" dataset to find matching parts. * Deletes duplicates by moving them to the end of the index. #### Code Snippet: ```markdown Sub PurgeCNCs() If Not OutPutData% Then Exit Sub Dim MainDB As Database, MainSet As Recordset Dim MachNamesDB As Database, MachNamesSet As Recordset Dim MachQDB As Database, MachQSet As Recordset Set MainDB = DBEngine.Workspaces(0).Databases(0) Set MachNamesDB = DBEngine.Workspaces(0).Databases(0) Set MachQDB = DBEngine.Workspaces(0).Databases(0) Set MachNamesSet = MachNamesDB.OpenRecordset("MachineNames", DB_OPEN_TABLE) Set MachQSet = MachQDB.OpenRecordset("Machines", DB_OPEN_TABLE) Set MainSet = MainDB.OpenRecordset("Process", DB_OPEN_TABLE) PartN$ = currform![PartNumber] MainSet.Index = "PrimaryKey" MachQSet.MoveFirst MachQSet.Index = "PartNumber" MachQSet.Seek "\u003e=", PartN$ If Not (MachQSet.NoMatch) Then Do While Trim$(MachQSet!PartNumber) = PartN$ A$ = MachQSet!Tool If (A$ = "***") Then MachQSet.Delete End If MachQSet.MoveNext If (MachQSet.EOF) Then Exit Do Loop End If currform.Refresh End Sub ``` #### Chunk 50 *Failed to generate documentation with Ollama* #### Chunk 51 **VBA Code Description** ======================== This VBA code is used to add records from a main database (`MainDB`) to two secondary databases (`Main2DB` and `Main2DB`) in an Excel application, specifically for tracking part information related to machines. ### Main Logic The code consists of several sections that perform the following actions: 1. **Loop through records**: The code loops through records in the main database, checking if a specific part number (`PartN$`) is present. 2. **Delete or update records**: Based on whether the generated flag is `True` for the current record, it either deletes the record from the main database and adds a new record to one of the secondary databases or updates an existing record in both databases. ### Functions The code calls several functions to manage the connection to the databases: * `XOPEN_Mains`: Opens the main database and creates a dynamic dataset (`MainSet`) for the "Process" table. * `XOPEN_Addnl`: Opens the additional process database and creates a dynamic dataset (`Main2Set`) for the "AddnlProc" table. * `XOPEN_Machs`: Opens the machine database and creates a dynamic dataset (`MainSet`) for the "Machines" table. * `XOPEN_Press`: Opens the press brake operations database and creates a dynamic dataset (`MainSet`) for the "PressBrakeOPs" table. ### Database Connections The code establishes connections to two databases: 1. **Main database** (`MainDB`): Used for storing main records. 2. **Secondary databases** (`Main2DB` and `Main2DB`): Used for adding or updating records related to machines. ### Error Handling If the part number is added successfully, an error message ("Part " + PartN$ + " added") is displayed and the subroutine exits. ### Dynamic Datasets The code uses dynamic datasets (`MainSet` and `Main2Set`) to interact with the databases. The datasets are used to perform operations such as moving to the first record, seeking records based on a condition, and updating fields. **Example Usage** ----------------- To use this code, follow these steps: 1. Open the Excel application. 2. Access the Visual Basic Editor by pressing `Alt + F11` or navigating to `Developer` \u003e `Visual Basic`. 3. Insert a new module by clicking `Insert` \u003e `Module` and paste the provided VBA code into the new module. 4. Connect to your databases using the relevant database connection settings (e.g., file path, username, password). 5. Run the subroutine by clicking `Run` \u003e `Run Sub/User Form`, selecting the main subroutine ("AddPartInfo"), or calling it programmatically. **Notes** --------- * The code assumes that the database tables and fields are already set up in the Excel application. * You should adjust the database connection settings, table names, and field names according to your specific requirements. * This code provides a basic structure for adding records from one database to another; you may need to modify it to fit your specific use case. #### Chunk 52 **Re-numbering Process for Press Brake Operations** This VBA code is designed to re-number process sheets for Press Brake Operations (PBOs) in a database. The script performs the following tasks: ### Initialization and Database Connection The code starts by setting up variables and establishing connections to the database. - `Main2Set` and `AddnlQSet` are created as dynamic datasets, allowing for easier manipulation of data. - `MainDB` and `MachDB` are referenced but not used in this script. It is assumed they are defined elsewhere. ### Recordset Management The code manages two main recordsets: - `Main2Set`: Used to iterate over the Press Brake OPs dataset, with the index set to "PartNumber". - `AddnlQSet`: Used to find and process generated records within the AddnlQ1 dataset. ### Re-numbering Process The re-numbering process involves the following steps: 1. **Find First Occurrence**: The code starts by finding the first occurrence of a record in `AddnlQSet` that matches the current part number. 2. **Delete Generated Records**: If the found record is generated (i.e., `Generated% = True`), it is deleted from the dataset. 3. **Find Next Occurrence**: The process then continues by finding the next occurrence of a record in `AddnlQSet`. ### Error Handling - An error handler (`ErrM$`) is defined to handle duplicate records, which are skipped using `Resume Next`. - A static variable `insertOp%` is used to store an insert operation count. ### User Interface Updates Throughout the re-numbering process, the code updates a user form's controls: - The caption of `txtCalcStat` is updated to reflect the progress of the script. ### Database Operations The script performs various database operations: - It opens and closes recordsets using `DB_OPEN_TABLE` and `DB_OPEN_DYNASET`. - It uses `DoEvents` to update the user interface while performing long-running tasks. ### Conclusion This VBA code is designed to re-number process sheets for Press Brake Operations in a database. The script iterates through generated records, deletes them if necessary, and updates the user interface to reflect its progress. #### Chunk 53 *Failed to generate documentation with Ollama* #### Chunk 54 *Failed to generate documentation with Ollama* #### Chunk 55 *Failed to generate documentation with Ollama* #### Chunk 56 **VBA Code Description** This VBA code appears to be generating a report or output based on various input parameters from a form (`currform`) and other variables. Here's a detailed breakdown of the code: ### Branching Logic The code uses an `Else`-`If` statement structure, which branches the execution flow based on conditions. **Case 1: Multiple Blanks Per Block** * If `BlanksPerBlock` is greater than 1 (`currform!BlanksPerBlock \u003e 1`), calculate `NumBlanks` as `BlanksPerBlock - 1`. * Print the calculated value of `NumBlanks`, formatted as "##0". * Check if there's an "Extra Shear" feature enabled. If yes, print the first cut value (`FirstCut!`) in "##0.000" format; otherwise, print the second cut value (`SecondCut!`). * Print additional values ("A2", "0", and "A0"). **Case 2: Specific Trim Cuts** * Check if either `Bottom_Trim_Cut` is greater than or equal to 2 or `ActualPartHeight` is greater than or equal to 2. * If true, calculate two variables (`FIRSTCUTLESSTOP` and `FIRSTCUTLESSBOTTOM`) based on the values of `FirstCut`, `TopTrim_Cut`, and other parameters. * Print formatted values for these variables in "##0.000" format. ### Output Formatting The code uses various formatting functions to create a human-readable output, including: * `Format$(Value, FormatString)`: formats a value as specified by the `FormatString`. * `FormitS$(Field, FormatString)`: formats a field as specified by the `FormatString`. ### Final Output The final output includes various fields, such as: * Part name and sheet information * Material and revision numbers * Additional metadata (e.g., "CNC" or "LASER" processing) * A unique identifier (`PartNumber`) Overall, this VBA code appears to be designed to generate a detailed report or output based on various input parameters and formatting rules. #### Chunk 57 **Detailed Description of VBA Code** ===================================== ### Sub 2nd Cut Shear File Generation This sub generates a 2nd cut shear file, which includes various parameters such as part details, material information, and calculations. #### Parameters Printed to File The following parameters are printed to the specified file (`#1`): * **Cut Type**: The type of cut (e.g., Laser or Shear) * **Part Name**: The name of the part * **Sheet Number**: The sheet number where the part is located * **Material Information**: * Material type (Gauge, etc.) * Part weight * Metal name (S/S, Col, Alu, Gal) * **Part Dimensions**: * Sheet width and length * Total sheet size * **Revision Number**: The current revision number of the part * **Part Number**: The unique identifier for the part #### Conditional Logic The code uses conditional logic to determine the type of cut based on various factors, such as: * Multi-cut or single-cut configuration * Laser cutting capability (e.g., LASER is not available) * Grain direction and orientation **Sub UtilGrossWt** ### Sub Calculating Gross Weight for a Part This sub calculates the gross weight of a part based on various input parameters. #### Parameters Passed to Sub The following parameters are passed to the sub: * `Sheet_W!` (sheet width) * `Sheet_L!` (sheet length) * `lb_per_sq_ft!` (material weight per square foot) * `Gw!` (gross weight variable, initialized to 0) * `Aw!` (weight calculation variable) * `MainSet As Recordset` (a recordset containing part information) #### Calculations and Logic The sub performs the following calculations: 1. Initializes variables for sheet length, width, and material weight 2. Checks for specific part numbers and updates grain direction accordingly 3. Calculates gross weight using various algorithms (e.g., calculating along first or second dimension) 4. Updates output data flags (`OutPutData%`) based on calculations **Sub Exit** ### Sub Exiting the Program This sub exits the program by closing the specified file (`#1`). #### Action Taken The sub simply closes the specified file and then exits the program. Note that this code appears to be part of a larger program, and additional context is required to fully understand its purpose and functionality. #### Chunk 58 **Detailed Markdown Description of VBA Code** ### Overview This VBA code appears to be part of a user interface for calculating utilization rates and other properties of metal sheets in a manufacturing process. It uses various variables and constants defined within the `MainSet` object to perform calculations and updates. ### Main Logic The code consists of two main logic branches: 1. **Calculating along only one dimension**: This branch is taken when the user selects "Calculated along only dimension" from the status dropdown menu. In this case, the code retrieves the grain direction (`GrNone%`) and updates it with the selected value before performing calculations. 2. **Calculating along multiple dimensions**: If the user selects a different option, the code performs calculations based on various assumptions and checks. ### Calculation Assumptions The code makes several assumptions about the input data: * The metal sheet is rectangular in shape. * There are two main dimensions: first dimension (`First_Dim!`) and second dimension (`Second_dim!`). * The sheet has a specific usage rate (`USAGE`) applied to its gross weight. * Various material properties, such as part height, width, and blank size, are specified. ### Calculation Logic The code performs various calculations based on the input data: * Calculates actual weight by multiplying gross weight with the usage rate. * Updates main set values: `GrossWt`, `ActualWt`, etc. * Calculates parts per sheet and blocks per sheet based on part blank size. ### Material Property Calculations The code performs calculations for material properties, including: * Part dimensions (`PartHeight!`, `PartWidth!`). * Blank size (`BlankSize!`). * Punching die description (`PunchDieDescr$`) and counter (`PunchCounter%`). ### Error Handling The code includes error handling mechanisms: * Checks for invalid input data, such as zero or negative values. * Uses constants to define error codes (e.g., `RC% = 6: GoSub Setcalcstat`). ### External Subroutines The code calls two external subroutines: * `UTCalcPart`: updates the main set with new values and performs calculations. * `Setcalcstat`: handles errors and updates the calculation status. Overall, this VBA code is designed to perform complex calculations for metal sheet utilization rates and other properties. It uses various assumptions and checks to ensure accurate results and includes error handling mechanisms to prevent errors. #### Chunk 59 **Code Description** ====================== This VBA code is part of a larger program that appears to be used for calculating material weights and dimensions for metal parts in various manufacturing processes, including CNC machining. The code contains several conditional statements and subroutines that handle different scenarios based on the input values and user selections. ### Overview ------------ The code starts by checking if `Multi$` is equal to "BLANK". If it is, the program exits or calls other subroutines depending on further conditions. If `Multi$` is not "BLANK", the program calculates material weights and dimensions based on various rules and user selections. ### Conditional Statements ------------------------- The code contains several conditional statements that handle different scenarios: 1. **First Cut Direction** * If `Multi$` is equal to "BLANK", the first cut direction is set to 1. * The program then checks the case of the first cut direction and performs calculations accordingly. 2. **Material Type** * Based on the value of `Multi$`, different material types are handled: * "LASER" or "SALVAGNINI": Part width is calculated as `(Sheet_Width! / Parts_Per_blank)` - Pt_Width!, and trim cuts are set to 0. * "SLUG": Part width is calculated similarly, but with a different formula. 3. **Material Weight Calculation** * The program calls the `UTDoAnswers` subroutine if `CalculationStatus` is equal to 0. * If `Multi$` is not equal to "BLANK", it calculates material weights using either `CalcMultGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!)` or `CalcGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!, RC%)`, depending on the case. 4. **Material Dimensions** * The program sets material dimensions based on the value of `Multi$`. * For "LASER" or "SALVAGNINI", part height and width are set as `(First_Dim! - TOP_TRIM_CUT! - Bottom_Trim_Cut!)` and `(PartWidth!)`, respectively. * For other material types, part height is set to `First_Dim!` or `Second_dim!`, and part width is set to either `PartWidth!` or `Second_dim!`. ### Subroutines ---------------- The code contains several subroutines that perform specific calculations: * **UTDoAnswers**: Handles material weight calculations based on user selections. * **CalcMultGrossWeight** (and its variants): Calculates material weights for various material types. ### Constants and Variables ----------------------------- The code uses several constants and variables, including: * `Multi$`: A string variable representing the type of material being processed. * `RC%`: An integer variable used to store calculation results. * `Gw!` and `Aw!`: Integer variables used as input values for calculations. * `OrigPartW!`, `PunchCounter%`, `Pt_Width!`, `First_Dim!`, `Second_dim!`, `Sheet Widt!`, `TOP_TRIM_CUT!`, `Bottom_Trim_Cut!`, and other variables related to material dimensions and processing conditions. ### Notes ------- * The code appears to be part of a larger program that handles various manufacturing processes. * Some parts of the code seem to be commented out or not fully implemented, indicating potential future modifications or additions. #### Chunk 60 **Detailed Description of VBA Code** ===================================== This VBA code appears to be part of a larger program that calculates various parameters for metal cutting operations. The code is written in a conditional-based structure, with multiple `Select Case` statements and nested logic to handle different scenarios. **Variables and Settings** --------------------------- The code assumes the existence of several variables, including: * `$` symbols denoting strings (e.g., `fc$`) * Percent signs indicating percentage values (e.g., `FirstCutDir%`) * `%` symbols for boolean flags (e.g., `ExtraShear%`) * `MainSet!` referencing a data table or settings object * `$` symbols for formatting numerical values **Code Structure** ------------------- The code is organized into several sections, each handling different scenarios: ### 1. Setting Defaults and Calculating Parameters ```markdown ' Set defaults and calculate parameters Select Case Else fc$ = MainSet![GrainDir] MainSet![PartHeight] = First_Dim! MainSet![ActualPartHeight] = First_Dim! MainSet![ActualPartWidth] = Second_dim! FirstCut! = First_Dim! SecondCut! = Second_dim! If Multi$ = "BLANK" Then FirstCutDir% = 1 End Select ' Calculate Actual_PartHeight and Actual_PartWidth Actual_PartHeight = MainSet![ActualPartHeight] Actual_PartWidth = MainSet![ActualPartWidth] If FirstCutDir% = 0 Then RC% = 1: GoSub Setcalcstat Else ' Update GrainDir, GrossWeight, etc. End If ' Calculate parts per sheet and blocks per sheet MainSet![PartsPerSheet] = parts_per_sheet! MainSet![BlocksPerSheet] = Blocks_Per_Sheet! MainSet![BlanksPerBlock] = Blanks_Per_Block! ' Format SheetSize and PartSize strings MainSet![SheetSize] = Format$(Sheet_Width!, "###0.000") + " X " + Format$(Sheet_Length!, "###0.000") If (Multi$ = "LASER") Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then MainSet![PartSize] = Format$(MainSet![PartHeight], "###0.000") + " X " + Format$(MainSet![PartWidth], "###0.000") Else MainSet![PartSize] = Format$(MainSet![ActualPartHeight], "###0.000") + " X " + Format$(MainSet![ActualPartWidth], "###0.000") End If ' Format BlankSize string MainSet![BlankSize] = Format$(First_Dim!, "###0.000") + " X " + Format$(Second_dim!, "###0.000") Return ``` This section sets default values, calculates `Actual_PartHeight` and `Actual_PartWidth`, and updates various settings and calculations based on the value of `Multi$`. ### 2. Material Weight Calculations ```markdown UTCalcMaterialWt: If (Multi$ = "NO CNC") And (Punch$ \u003c\u003e "!NONE!") And (MainSet!PunchOption = 2) And (Sheet_Width \u003c\u003e Second_dim!) Then RC% = 2: GoSub Setcalcstat FirstCutDir% = 0 End If If Multi$ = "MULTIPLE" Or Multi$ = "LASER" Or (Multi$ = "SALVAGNINI") Or (Multi$ = "LASER/SHEAR") Or (Multi$ = "SLUG") Then ' Calculate part width and call CalcMultGrossWeight Part_Width = MainSet![PartWidth] Call CalcMultGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!) FirstCutDir% = 1 Else ' Check grain direction and calculate gross weight using CalcGrossWeight or other methods End If ``` This section handles material weight calculations for different scenarios, including multiple cuts, laser/salvagnini operations, and other conditions. ### 3. Checking Grain Direction and Calculating Gross Weight ```markdown If Not (Grain$, 11) = "ALONG FIRST" Then ' Calculate gross weight using CalcGrossWeight with grain direction as second argument End If ``` This section checks the grain direction and calculates the gross weight using `CalcGrossWeight` or other methods. ### 4. Error Handling ```markdown GoSub Setcalcstat ' Handle errors or exceptions by invoking Setcalcstat subroutine ``` This section invokes an error handling subroutine, `Setcalcstat`, to handle any errors or exceptions that may occur during execution. Note that the code is not fully commented and appears to be part of a larger program. The above description provides a general overview of the structure and logic of the code. #### Chunk 61 **VBA Code Description** ### Main Calculation Logic The code consists of two main sections: the calculation logic and the cross-reference check. #### Calculation Logic ```markdown If Gw1! = Gw2! Then If First_Dim! \u003c Second_dim! Then FirstCutDir% = 1 Call CalcGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!, RC%) Else FirstCutDir% = 2 Call CalcGrossWeight(Second_dim!, First_Dim!, Gw!, Aw!, RC%) End If Else If First_Dim! \u003c Second_dim! Then FirstCutDir% = 2 Call CalcGrossWeight(First_Dim!, Second_dim!, Gw!, Aw!, RC%) Else FirstCutDir% = 1 Call CalcGrossWeight(Second_dim!, First_Dim!, Gw!, Aw!, RC%) End If End If ``` This logic is used to determine the correct calculation order for two sets of dimensions, `First_Dim!` and `Second_dim!`. The code checks if the Gross Weights (`Gw1!` and `Gw2!`) are equal. If they are: * If `First_Dim!` is less than `Second_dim!`, it sets `FirstCutDir%` to 1 and calls `CalcGrossWeight` with these dimensions, Gross Weight, Air Volume (Aw), and Resultant Cutting Direction (RC). * Otherwise, it sets `FirstCutDir%` to 2 and calls `CalcGrossWeight` with the opposite set of dimensions. If the Gross Weights are not equal: * If `First_Dim!` is less than `Second_dim!`, it sets `FirstCutDir%` to 2 and calls `CalcGrossWeight` with these dimensions, Gross Weight, Air Volume, and Resultant Cutting Direction. * Otherwise, it sets `FirstCutDir%` to 1 and calls `CalcGrossWeight` with the opposite set of dimensions. The code also includes a return statement at the end of this logic block. #### Calculation Status Update ```markdown Setcalcstat: MainSet![CalculationStatus] = RC% Return ``` This subroutine updates the calculation status in the `MainSet!` object with the result of the previous calculation (`RC%`) and returns. ### Cross-Reference Check The following code is a separate subroutine that checks for cross-references between parts: ```markdown Sub CrossRef() ' ... End Sub ``` #### Main Logic This subroutine: 1. Hides certain controls on the form. 2. Shows a message indicating it's searching for a cross-reference file. 3. Sets up a dynamic recordset to query the RMSFILES#_EGSSP1A0 table in the database. 4. Checks if there are any records in the recordset. 5. If yes, it loops through each record and checks if the part number or new part number match the `PartN$` variable. 6. If a match is found, it shows a message indicating that the part has an associated part and sets up the 300 series command to be visible. #### Control Visibility and Caption After finding any cross-references, the subroutine: 1. Hides the calculation status controls. 2. Sets the calculation status text to "Waiting for Calculate". 3. Shows the control for deleting files from Trumpfs. 4. Hides other controls on the form. This code seems to be part of a larger system that involves calculating weights and dimensions for parts, as well as checking for cross-references between parts in a database.