PSLine2000Documentation/Forms/DS Shear.md

5.2 KiB

DS Shear

Analysis generated on: 4/1/2025 4:10:37 PM

Record Source

Controls

Control Name Reference
PartNumber PartNumber (from Queries/DataSheetQ1)
Operation Operation (from Queries/DataSheetQ1)
Elem1A Elem1A (from Queries/DataSheetQ1)
Paperwork Paperwork (from Queries/DataSheetQ1)
TotalSelectTime TotalSelectTime (from Queries/DataSheetQ1)
StandardMinutes/part StandardMinutes/part (from Queries/DataSheetQ1)
pf&d pf&d (from Queries/DataSheetQ1)
StandardHours/part StandardHours/part (from Queries/DataSheetQ1)
StandardParts StandardParts (from Queries/DataSheetQ1)
Elem1V1 Elem1V1 (from Queries/DataSheetQ1)
Elem1V2 Elem1V2 (from Queries/DataSheetQ1)
Elem1V3 Elem1V3 (from Queries/DataSheetQ1)
Elem2A Elem2A (from Queries/DataSheetQ1)
Elem2V1 Elem2V1 (from Queries/DataSheetQ1)
Elem2V2 Elem2V2 (from Queries/DataSheetQ1)
Elem2V3 Elem2V3 (from Queries/DataSheetQ1)
Elem3A Elem3A (from Queries/DataSheetQ1)
Elem3V1 Elem3V1 (from Queries/DataSheetQ1)
Elem3V2 Elem3V2 (from Queries/DataSheetQ1)
Elem3V3 Elem3V3 (from Queries/DataSheetQ1)
Elem4A Elem4A (from Queries/DataSheetQ1)
Elem4V1 Elem4V1 (from Queries/DataSheetQ1)
Elem4V2 Elem4V2 (from Queries/DataSheetQ1)
Elem4V3 Elem4V3 (from Queries/DataSheetQ1)
Elem5A Elem5A (from Queries/DataSheetQ1)
Elem5V1 Elem5V1 (from Queries/DataSheetQ1)
Elem5V2 Elem5V2 (from Queries/DataSheetQ1)
Elem5V3 Elem5V3 (from Queries/DataSheetQ1)
Elem6A Elem6A (from Queries/DataSheetQ1)
Elem6V1 Elem6V1 (from Queries/DataSheetQ1)
Elem6V2 Elem6V2 (from Queries/DataSheetQ1)
Elem6V3 Elem6V3 (from Queries/DataSheetQ1)
Field362 Elem7A (from Queries/DataSheetQ1)
Field364 Elem7V1 (from Queries/DataSheetQ1)
Elem7V2 Elem7V2 (from Queries/DataSheetQ1)
Elem7V3 Elem7V3 (from Queries/DataSheetQ1)
Elem8A Elem8A (from Queries/DataSheetQ1)
Elem8V1 Elem8V1 (from Queries/DataSheetQ1)
Elem8V2 Elem8V2 (from Queries/DataSheetQ1)
Elem8V3 Elem8V3 (from Queries/DataSheetQ1)
Elem9A Elem9A (from Queries/DataSheetQ1)
Elem9V1 Elem9V1 (from Queries/DataSheetQ1)
Elem9V2 Elem9V2 (from Queries/DataSheetQ1)
Elem9V3 Elem9V3 (from Queries/DataSheetQ1)
Elem10A Elem10A (from Queries/DataSheetQ1)
Elem10V1 Elem10V1 (from Queries/DataSheetQ1)
Elem10V2 Elem10V2 (from Queries/DataSheetQ1)
Text415 Elem11A (from Queries/DataSheetQ1)

VBA Code

Option Compare Database   'Use database order for string comparisons

Private Sub Form_Load()
   On Error GoTo die
   If IsNull(Me![PartNumber]) Then
      End
   End If
Exit Sub
HelpMe:
    DoCmd.SelectObject A_FORM, "DS Shear"
    DoCmd.Close
Exit Sub
die:
   Resume HelpMe

End Sub

What it does

VBA Code Description: Form Load Event Handler

Overview

This VBA code snippet is attached to the Form_Load event of a Microsoft Access database form. It serves as a handler for the event that occurs when the form loads.

Purpose

The primary purpose of this code is to ensure that the form is not loaded if it lacks a required input, specifically the PartNumber.

Key Features

  • Error Handling: The code uses On Error GoTo die to catch any errors that might occur during execution. This ensures that the program doesn't crash and provides an alternative path for handling errors.
  • Null Check: It checks if the PartNumber field is null (IsNull) before proceeding with the rest of the code.
  • Exit Sub Statement: If the PartNumber is null, the code exits the subroutine immediately using the End statement. This prevents further execution and ensures that the form does not load.
  • HelpMe Label: The code uses a DoCmd.SelectObject A_FORM, "DS Shear" command to close an existing form named "DS Shear" before exiting. This suggests that there might be some other form-related functionality tied to this event handler.

Step-by-Step Explanation

  1. When the form loads, the Form_Load event is triggered.
  2. The code checks for any errors using On Error GoTo die. If an error occurs, it redirects control to the die label.
  3. It then verifies if the PartNumber field contains a null value (IsNull Me![PartNumber]). If it's null, the program exits using the End statement.
  4. After checking for errors and handling the case where PartNumber is null, the code executes a DoCmd.SelectObject A_FORM, "DS Shear" command to close an existing form named "DS Shear".
  5. If no errors occur or if the PartNumber field has a valid value, the program exits normally using the Exit Sub statement.

Conclusion

This VBA code provides a robust and error-free way to handle the loading of a specific form in Microsoft Access. By integrating null checks, error handling, and exit statements, it ensures that the form loads successfully only if all required inputs are present.