85 lines
3.2 KiB
Markdown
85 lines
3.2 KiB
Markdown
# DS Hand Deburr
|
|
---
|
|
## Record Source
|
|
- [[Queries/DataSheetQ1]]
|
|
## 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]]) |
|
|
| Elem2V2 | Elem2V1 (from [[Queries/DataSheetQ1]]) |
|
|
| Field469 | Elem3A (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 Hand Deburr"
|
|
DoCmd.Close
|
|
Exit Sub
|
|
die:
|
|
Resume HelpMe
|
|
|
|
End Sub
|
|
|
|
```
|
|
## What it does
|
|
**Code Description: Form Load Event Handler in VBA**
|
|
|
|
### Overview
|
|
|
|
This is a Visual Basic for Applications (VBA) code snippet that handles the form load event in a Microsoft Office application. Specifically, it's designed to work with forms and databases.
|
|
|
|
### Code Breakdown
|
|
|
|
#### `Option Compare Database`
|
|
|
|
* This line sets the comparison type for string comparisons in the VBA editor.
|
|
* It specifies that database order should be used for string comparisons.
|
|
* This can affect how strings are compared when using string data types (e.g., text fields).
|
|
|
|
#### `Private Sub Form_Load()`
|
|
|
|
* This is a subprocedure that runs automatically when the form loads.
|
|
* The `Form_Load` event is triggered after the form has been opened, and before any other events occur.
|
|
|
|
#### `On Error GoTo die`
|
|
|
|
* This line sets up error handling for the subroutine.
|
|
* If an error occurs while executing the code in this subroutine, the program will jump to the label `die`.
|
|
|
|
#### `If IsNull(Me![PartNumber]) Then End`
|
|
|
|
* This conditional statement checks if the value of the field named "PartNumber" in the form is null (i.e., empty or undefined).
|
|
* If it is null, the subroutine ends without performing any further actions.
|
|
|
|
#### `Exit Sub HelpMe: DoCmd.SelectObject A_FORM, "DS Hand Deburr" DoCmd.Close`
|
|
|
|
* This block of code performs several actions:
|
|
+ `HelpMe:`: This label serves as a catch-all error handler for the program.
|
|
+ `DoCmd.SelectObject A_FORM`: Selects an existing form named "DS Hand Deburr".
|
|
+ `DoCmd.Close`: Closes the selected form.
|
|
|
|
#### `die: Resume HelpMe`
|
|
|
|
* If an error occurs while executing the code in this subroutine, the `die` label will be reached.
|
|
* The `Resume` statement then transfers control back to the `HelpMe:` label.
|
|
|
|
### Context and Usage
|
|
|
|
This code is likely used in a Microsoft Office application (such as Excel or Access) that requires handling form load events. The specific actions performed in this subroutine depend on the requirements of the application, but they seem to be related to selecting an existing form and closing it.
|