PSLine2000Documentation/Forms/DS CNC.md

93 lines
3.4 KiB
Markdown

# DS CNC
---
## Record Source
- [[Queries/DataSheetQ1]]
## Controls
| Control Name | Reference |
|--------------|-----------|
| PartNumber | PartNumber (from [[Queries/DataSheetQ1]]) |
| Operation | Operation (from [[Queries/DataSheetQ1]]) |
| Elem1A | Elem1A (from [[Queries/DataSheetQ1]]) |
| Elem2A | Elem2A (from [[Queries/DataSheetQ1]]) |
| Elem3A | Elem3A (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]]) |
| Elem4A | Elem4A (from [[Queries/DataSheetQ1]]) |
| Elem5A | Elem5A (from [[Queries/DataSheetQ1]]) |
| Elem5V1 | Elem5V1 (from [[Queries/DataSheetQ1]]) |
| Elem5V2 | Elem5V2 (from [[Queries/DataSheetQ1]]) |
| Elem6A | Elem6A (from [[Queries/DataSheetQ1]]) |
| Field85 | Elem7V3 (from [[Queries/DataSheetQ1]]) |
| Field90 | Elem7V1 (from [[Queries/DataSheetQ1]]) |
| Field91 | Elem7V2 (from [[Queries/DataSheetQ1]]) |
| Field92 | Elem7A (from [[Queries/DataSheetQ1]]) |
## VBA Code
```vba
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 CNC"
DoCmd.Close
Exit Sub
die:
Resume HelpMe
End Sub
```
## What it does
**Code Description**
=====================
### Overview
This VBA code snippet is a procedure that is triggered when the `Form_Load` event occurs in an Access database. It checks for specific conditions and performs actions accordingly.
### Detailed Breakdown
#### Option Compare Database
The first line of code specifies the comparison order to use when comparing strings in this scope. In this case, it's set to "Database", which means that string comparisons will be performed according to the database's sorting order.
#### Private Sub Form_Load()
This is the procedure name and event handler for the `Form_Load` event, which occurs when a form is loaded.
#### On Error GoTo die
The `On Error` statement specifies an error handling routine that will be executed if any errors occur within the code. In this case, it jumps to the label `die`.
#### If IsNull(Me![PartNumber]) Then End
This line checks if the value in the `PartNumber` control on the form (`Me![PartNumber]`) is null (i.e., an empty string). If so, the procedure ends.
#### Exit Sub
The `Exit Sub` statement immediately exits the procedure without executing any further code.
#### HelpMe:
This label marks the beginning of a separate error handling block that will be executed if an error occurs. It consists of three commands:
* `DoCmd.SelectObject A_FORM, "DS CNC"`: Selects a form named "DS CNC" as the active form.
* `DoCmd.Close`: Closes the currently active form.
* `Exit Sub`: Exits the procedure.
#### die:
This label marks the end of the error handling block. The `Resume` statement resumes execution from this point if an error occurred in the preceding code.
### Purpose
The purpose of this code is to ensure that certain conditions are met before allowing the form to load. If these conditions are not met, it provides alternative actions and exits.