5.2 KiB
5.2 KiB
Util Result1
Record Source
Controls
| Control Name | Reference |
|---|---|
| ACTIV | ACTIV (from Tables/Util Selection C1) |
| PHANT | PHANT (from Tables/Util Selection C1) |
| MAKE# | MAKE# (from Tables/Util Selection C1) |
| ITTYP | ITTYP (from Tables/Util Selection C1) |
| USAGE | USAGE (from Tables/Util Selection C1) |
| PMNAS | PMNAS (from Tables/Util Selection C1) |
| WOQTY | WOQTY (from Tables/Util Selection C1) |
| BSIZE2 | BSIZE2 (from Tables/Util Selection C1) |
| PartNumber | PartNumber (from Tables/Util Selection C1) |
| Flag | Flag (from Tables/Util Selection C1) |
| PartName | PartName (from Tables/Util Selection C1) |
| CutType | CutType (from Tables/Util Selection C1) |
| PunchOption | PunchOption (from Tables/Util Selection C1) |
| PunchNumber | PunchNumber (from Tables/Util Selection C1) |
| PunchPartsPerStrip | PunchPartsPerStrip (from Tables/Util Selection C1) |
| PunchStd | PunchStd (from Tables/Util Selection C1) |
| GrainDir | GrainDir (from Tables/Util Selection C1) |
| GrainNone | GrainNone (from Tables/Util Selection C1) |
| FirstDim | FirstDim (from Tables/Util Selection C1) |
| SecDim | SecDim (from Tables/Util Selection C1) |
| PartsPerBlank | PartsPerBlank (from Tables/Util Selection C1) |
| PartsPerSheet | PartsPerSheet (from Tables/Util Selection C1) |
| BlocksPerSheet | BlocksPerSheet (from Tables/Util Selection C1) |
| BlanksPerBlock | BlanksPerBlock (from Tables/Util Selection C1) |
| PartHeight | PartHeight (from Tables/Util Selection C1) |
| PartWidth | PartWidth (from Tables/Util Selection C1) |
| BotTrimCut | BotTrimCut (from Tables/Util Selection C1) |
| TopTrimCut | TopTrimCut (from Tables/Util Selection C1) |
| ActualPartHeight | ActualPartHeight (from Tables/Util Selection C1) |
| ActualPartWidth | ActualPartWidth (from Tables/Util Selection C1) |
| PartSize | PartSize (from Tables/Util Selection C1) |
| GrossWt | GrossWt (from Tables/Util Selection C1) |
| ActualWt | ActualWt (from Tables/Util Selection C1) |
| Utilization | Utilization (from Tables/Util Selection C1) |
| SheetSize | SheetSize (from Tables/Util Selection C1) |
| CalculationStatus | CalculationStatus (from Tables/Util Selection C1) |
| Field113 | MetalType (from Tables/Util Selection C1) |
| Field113 (Row Source) | Tables/[metalQ1]; |
| BestSheetSet | BestSheetSet (from Tables/Util Selection C1) |
| HOUSE | HOUSE (from Tables/Util Selection C1) |
VBA Code
Option Compare Database
Option Explicit
Private Sub Command120_Click()
On Error GoTo Err_Command120_Click
DoCmd.GoToRecord , , acNext
Exit_Command120_Click:
Exit Sub
Err_Command120_Click:
MsgBox Err.Description
Resume Exit_Command120_Click
End Sub
What it does
Code Description
Overview
The provided VBA code is a subroutine named Command120_Click which appears to be part of an Access database application. This code snippet handles the click event of a button with the command ID 120.
Code Breakdown
Option Declarations
Option Compare Database: This line tells Visual Basic that strings should be compared using the database comparison rules, ensuring that uppercase and lowercase letters are treated as equal.Option Explicit: This option forces all variable declarations to be explicit. In other words, it ensures that variables declared within a subroutine or module must have their data type specified.
Subroutine Definition
Private Sub Command120_Click()
This line defines the Command120_Click subroutine, which is triggered when the button with command ID 120 is clicked.
Error Handling
On Error GoTo Err_Command120_Click: This statement sets up error handling by specifying that if an error occurs in the code within this subroutine (betweenPrivate Sub Command120_Click()and the firstExitstatement), it should jump to the label marked asErr_Command120_Click.DoCmd.GoToRecord , , acNext: If no errors occur, this line executes theGoToRecordmethod of theDoCmdobject. TheacNextconstant specifies that after navigating to a record, Access should proceed to navigate to the next record.
Error Handling Resume
Exit_Command120_Click:
Exit Sub
Err_Command120_Click:
MsgBox Err.Description
Resume Exit_Command120_Click
Exit_Command120_Click: This label marks the end of the subroutine if there are no errors. TheExit Substatement terminates the execution of the subroutine.Err_Command120_Click: If an error does occur, this label is executed instead. It displays a message box containing the description of the error usingMsgBox Err.Description. After displaying the error message, it resumes execution at theExit_Command120_Clicklabel, effectively retrying the failed operation.
Best Practices
- The code makes use of robust error handling to provide useful feedback in case something goes wrong.
- It adheres to explicit variable declarations and follows Access-specific command IDs for button commands.