PSLine2000Documentation/Forms/Parts Per Sheet.md

2.6 KiB

Parts Per Sheet

Analysis generated on: 4/1/2025 4:05:46 PM

Record Source

  • None

Controls

Control Name Reference
Cut Type (Row Source)

VBA Code

Option Compare Database

Private Sub Cut_Type_Click()
A$ = Me![Cut Type]
If A$ = "Multiple" Then
Parting_Tool.Value = 0.2
Trim_Cut_Bottom.Value = 2.25
Me![Parting Tool].Visible = True
Me![Trim Cut Top].Visible = True
Me![Trim Cut Bottom].Visible = True
 Else
Parting_Tool.Value = 0
Trim_Cut_Bottom.Value = 0
Me![Parting Tool].Visible = False
Me![Trim Cut Top].Visible = False
Me![Trim Cut Bottom].Visible = False
End If
End Sub

What it does

Cut Type Click Event Handler

Overview

This VBA code is a click event handler for a button control named "Cut Type". When the button is clicked, it updates various properties and visibility settings of other controls in the worksheet.

Code Breakdown

Option Comparison

The first line Option Compare Database sets the comparison type to Database. This is used to ensure consistent string comparisons across all instances of the code.

Sub Procedure

The Private Sub Cut_Type_Click() subroutine is defined to handle the click event of the "Cut Type" button.

Variable Declaration and Initialization

  • A$: A string variable that stores the value of the selected cut type. It is assigned the value of the "Cut Type" control using Me![Cut Type].
  • Parting_Tool and Trim_Cut_Bottom: Object variables that reference two other controls in the worksheet.

Conditional Logic

The code uses an if-else statement to determine the action to take based on the selected cut type:

Multiple Cut Type

  • Set Parting_Tool.Value to 0.2.
  • Set Trim_Cut_Bottom.Value to 2.25.
  • Show the "Parting Tool" control by setting its visibility to True using Me![Parting Tool].Visible = True.
  • Show the "Trim Cut Top" and "Trim Cut Bottom" controls by setting their visibility to True using Me![Trim Cut Top].Visible = True and Me![Trim Cut Bottom].Visible = True, respectively.

Other Cut Types

  • Set Parting_Tool.Value to 0.
  • Set Trim_Cut_Bottom.Value to 0.
  • Hide the "Parting Tool" control by setting its visibility to False using Me![Parting Tool].Visible = False.
  • Hide the "Trim Cut Top" and "Trim Cut Bottom" controls by setting their visibility to False using Me![Trim Cut Top].Visible = False and Me![Trim Cut Bottom].Visible = False, respectively.

Conclusion

When the "Cut Type" button is clicked, this code updates various properties and visibility settings of other controls in the worksheet based on the selected cut type.