4.8 KiB
DS Misc Weld
Record Source
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) |
Field97 | Elem1V1 (from Queries/DataSheetQ1) |
Field98 | Elem1V2 (from Queries/DataSheetQ1) |
Field100 | Elem2V1 (from Queries/DataSheetQ1) |
Field105 | Elem3V1 (from Queries/DataSheetQ1) |
Field140 | Elem6A (from Queries/DataSheetQ1) |
Field144 | Elem7A (from Queries/DataSheetQ1) |
Field158 | Elem8V1 (from Queries/DataSheetQ1) |
Field161 | Elem8V2 (from Queries/DataSheetQ1) |
Field164 | Elem8V3 (from Queries/DataSheetQ1) |
Field167 | Elem9V1 (from Queries/DataSheetQ1) |
Field170 | Elem9V2 (from Queries/DataSheetQ1) |
Field173 | Elem9V3 (from Queries/DataSheetQ1) |
Field179 | Elem8A (from Queries/DataSheetQ1) |
Field180 | Elem8A (from Queries/DataSheetQ1) |
Field196 | Elem4V1 (from Queries/DataSheetQ1) |
Field197 | Elem5V1 (from Queries/DataSheetQ1) |
Field198 | Elem6V1 (from Queries/DataSheetQ1) |
Field202 | Elem6V2 (from Queries/DataSheetQ1) |
Field211 | Elem10V1 (from Queries/DataSheetQ1) |
Field214 | Elem10V2 (from Queries/DataSheetQ1) |
Field217 | Elem10V3 (from Queries/DataSheetQ1) |
Field220 | Elem11V1 (from Queries/DataSheetQ1) |
Field223 | Elem11V2 (from Queries/DataSheetQ1) |
Field226 | Elem11V3 (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 CNC"
DoCmd.Close
Exit Sub
die:
Resume HelpMe
End Sub
What it does
Code Description
Option Compare Database
This line specifies that string comparisons in the code should be performed using the database's order. This means that even if two strings are treated as equal by the .NET framework, they may not be considered equal by this specific VBA application.
Private Sub Form_Load()
This is a subroutine named Form_Load
which is called when the form is loaded. It contains three main sections: error handling, form validation, and default action.
On Error GoTo die
If an error occurs in the code within the Form_Load
subroutine, it will be caught by this line and the program execution will continue to the next section labeled "die".
If IsNull(Me![PartNumber]) Then
This checks if the PartNumber
field on the form is null. The Me
keyword refers to the current object (in this case, the form). The [PartNumber]
syntax is used to access a control on the form by its name.
If the PartNumber
field is null, the program will exit immediately using the End
statement.
Exit Sub
This line exits the subroutine and returns the program execution to the next event or command. In this case, it's likely that the program has finished loading and there are no further actions required.
HelpMe:
This section contains two subroutines: DoCmd.SelectObject
and DoCmd.Close
. These subroutines interact with the database and are used to manage forms.
DoCmd.SelectObject A_FORM, "DS CNC"
: This line selects an object named "DS CNC" from the database. TheA_FORM
argument specifies that a form should be selected.DoCmd.Close
: This line closes the currently active form. In this case, it's closing the form with the name "DS CNC".Exit Sub
: After closing the form, the program exits the subroutine and returns to the next event or command.
die:
This section contains a single instruction: Resume HelpMe
. If an error occurs in the code within the Form_Load
subroutine, this line will resume execution from the HelpMe
label. This effectively "catches" any errors that occur during form loading and takes alternative action instead.
In summary, this VBA code is responsible for checking if a form has been loaded successfully, handling any potential errors by catching them and taking alternative actions, and then selecting and closing another form in the database if necessary.