3.7 KiB
3.7 KiB
Miscellaneous
Record Source
- None
Controls
| Control Name | Reference |
|---|---|
| None | - |
VBA Code
Option Compare Database
Option Explicit
Private Sub cmdOpen14two_Click()
On Error GoTo Err_cmdOpen14two_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "14 two"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdOpen14two_Click:
Exit Sub
Err_cmdOpen14two_Click:
MsgBox Err.Description
Resume Exit_cmdOpen14two_Click
End Sub
Private Sub Command16_Click()
On Error GoTo Err_Command16_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "14" + Chr$(34) + " Process Sheet"
DoCmd.OpenForm stDocName
Forms![14" Process Sheet].recordSource = "Processes by List"
Exit_Command16_Click:
Exit Sub
Err_Command16_Click:
MsgBox Err.Description
Resume Exit_Command16_Click
End Sub
Private Sub Utilization_Form_Click()
On Error GoTo Err_Utilization_Form_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Utilization on Multiple Sheets"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Utilization_Form_Click:
Exit Sub
Err_Utilization_Form_Click:
MsgBox Err.Description
Resume Exit_Utilization_Form_Click
End Sub
Private Sub Gross_Weight_Click()
On Error GoTo Err_Gross_Weight_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Sheet Metal Weight"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Gross_Weight_Click:
Exit Sub
Err_Gross_Weight_Click:
MsgBox Err.Description
Resume Exit_Gross_Weight_Click
End Sub
What it does
Code Description
The provided VBA code is a set of event-driven procedures written in Microsoft Access's Visual Basic for Applications (VBA) language. These procedures are designed to handle the click events of specific commands in an Access database.
Common Patterns and Structure
All the procedures follow a similar pattern:
- Define error handling blocks using
On Error GoTo Err_[ProcedureName]statements. - Declare variables for document names (
stDocName) and link criteria (stLinkCriteria). - Set the values for these variables based on the procedure's purpose.
- Use
DoCmd.OpenFormto open a specific form in the database, passing the declared variables as arguments. - Handle successful execution with an
Exit_ProcedureName:label, which exits the procedure cleanly. - Catch and display any errors that occur using an
Err_[ProcedureName]_Click:block, then resumes execution from the corresponding error-handling label.
Procedure Descriptions
cmdOpen14two_Click()
This procedure is triggered when a command button labeled "cmdOpen14two" is clicked.
- Opens a specific form named "14 two".
- The form opening process uses
DoCmd.OpenFormwith no specified link criteria.
Command16_Click()
When the command button labeled "Command 16" is clicked, this procedure executes:
- Opens a form named "14" + Chr(34) + " Process Sheet".
- Sets the record source of an active form to "Processes by List".
Utilization_Form_Click()
This event handler opens a specific form called "Utilization on Multiple Sheets":
- Uses
DoCmd.OpenFormwithout any link criteria.
Gross_Weight_Click()
When the command button labeled "Gross Weight" is clicked, this procedure executes:
- Opens a form named "Sheet Metal Weight".
Key Takeaways
- Each procedure handles a specific click event on a command button.
- The procedures share a common pattern for error handling and form opening.
- The code provides basic functionality for managing forms in an Access database.