PSLine2000Documentation/Forms/DS Shake And Break.md

3.4 KiB

DS Shake And Break

Analysis generated on: 4/1/2025 4:05:07 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)
Elem2A Elem2A (from Queries/DataSheetQ1)
Field469 Elem3A (from Queries/DataSheetQ1)
Elem1V1 Elem1A (from Queries/DataSheetQ1)
Elem2V1 Elem2A (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 Hand Deburr"
    DoCmd.Close
Exit Sub
die:
   Resume HelpMe

End Sub

What it does

VBA Code Description

Overview

This VBA code is written in Access and is used to handle the form load event. It ensures that when a form is loaded, certain actions are taken to prevent errors.

Breakdown of the Code

Option Compare Database

The first line sets the option for string comparisons to use the database order. This means that when comparing strings, the code will use the collation sequence defined in the database, which can affect how strings are compared and sorted.

Private Sub Form_Load()

This is a subroutine declared as private, meaning it can only be accessed within the same module. The Form_Load event is triggered whenever a form is loaded.

On Error GoTo die

The On Error statement specifies that if an error occurs in the code, the control should jump to the label die.

If IsNull(Me![PartNumber]) Then End

This checks if the value of the field named "PartNumber" on the current form is null or empty. If it is, the subroutine will exit immediately using the End statement.

DoCmd.SelectObject A_FORM, "DS Hand Deburr"

If the part number field is not null or empty, this line uses the DoCmd.SelectObject method to open a form named "DS Hand Deburr". The A_FORM parameter refers to the current form.

DoCmd.Close

After opening the other form, this line closes the current form using the DoCmd.Close method.

Exit Sub

The Exit Sub statement exits the subroutine after all code within it has been executed.

HelpMe: ... (commented out)

This is a commented-out line that jumps to the label named "HelpMe" if an error occurs. It's likely that this was used for debugging purposes but has been disabled.

die:

This is the label where the control should jump if an error occurs, following the On Error GoTo statement.

Purpose

The purpose of this code is to ensure that when a form is loaded, certain actions are taken to prevent errors. Specifically, it checks if the part number field is null or empty and handles this situation by opening another form and closing the current one. If an error occurs, it jumps to a labeled point for further debugging.