5.9 KiB
5.9 KiB
Filtered Parts
Analysis generated on: 4/1/2025 4:09:54 PM
Record Source
- None
Controls
Control Name | Reference |
---|---|
None | - |
VBA Code
Option Compare Database
Private Sub Command13_Click()
Dim MainDB As Database, MainSet As Recordset
Dim MainDB2 As Database, MainSet2 As Recordset
Set MainDB = DBEngine.Workspaces(0).Databases(0)
Set MainDB2 = DBEngine.Workspaces(0).Databases(0)
lblstatus.Caption = "Setting up Database"
Dim stDocName As String
lblstatus.Caption = "Moving Parts to AS400"
Set MainSet = MainDB.OpenRecordset("RMSFILES#_IEMUP1A0") ' Create dynaset.
Set MainSet2 = MainDB2.OpenRecordset("Filtered Parts") ' Create dynaset.
lblstatus.Caption = "Purging AS400 product number file"
On Error Resume Next
MainSet.MoveFirst
On Error GoTo 0
Do
If Not (MainSet.EOF) Then
MainSet.Delete
DoEvents
Else
DoEvents
Exit Do
End If
MainSet.MoveNext
Loop
'"Purging AS400 result file"
MainSet2.MoveFirst
Do
If Not (MainSet2.EOF) Then
p$ = MainSet2!PartNumber
MainSet.AddNew
MainSet!PRDNO = p$
On Error Resume Next
MainSet.Update
On Error GoTo 0
DoEvents
Else
DoEvents
Exit Do
End If
MainSet2.MoveNext
Loop
lblstatus.Caption = "Activating AS400 Program"
DoEvents
ActiveXCtl24.DoClick
lblstatus.Caption = "Putting Parts in 'Process By List' Table"
stDocName = "Filtered Parts 4"
DoCmd.OpenQuery stDocName, acNormal, acEdit
lblstatus.Caption = "Done!!!! You can view Spread Sheet or Process Sheet"
Exit_Command13_Click:
Exit Sub
Err_Command13_Click:
MsgBox Err.Description
Resume Exit_Command13_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 Command18_Click()
lblstatus.Caption = "Filtering Parts"
stDocName = "Filtered Parts 2"
DoCmd.OpenQuery stDocName, acNormal, acEdit
lblstatus.Caption = "Ready for the next button"
End Sub
Private Sub Command20_Click()
DoCmd.OpenTable "Filtered Parts", acViewNormal
lblstatus.Caption = "Don't Forget To Modify any Queries Before Running Parts"
End Sub
Private Sub Command22_Click()
DoCmd.OpenQuery "Filtered Parts 4", acViewDesign
lblstatus.Caption = "Ready to Run Parts Through AS-400"
End Sub
Private Sub Command23_Click()
DoCmd.OpenQuery "Filtered Parts 3", acViewNormal
End Sub
Private Sub Command24_Click()
DoCmd.OpenQuery "Filtered Parts 3", acViewDesign
lblstatus.Caption = "Check the Final Querie for any additional changes"
End Sub
What it does
VBA Code Description
This VBA code is written in Access and appears to be part of an inventory management system. It handles various tasks related to filtering, processing, and activating parts data.
Command13_Click
- Purpose: This subroutine is triggered when a button with ID 13 is clicked.
- Steps:
- Opens two databases (
MainDB
andMainDB2
) and sets up Recordsets for "RMSFILES#_IEMUP1A0" and "Filtered Parts". - Purgues the AS400 product number file by deleting all records in the first Recordset.
- Moves data from the second Recordset to the first Recordset, mapping PartNumber to PRDNO fields.
- Activates an AS400 program using ActiveX Control 24 and updates a process sheet query.
- Displays a status message indicating completion.
- Opens two databases (
Command16_Click
- Purpose: This subroutine is triggered when another button with ID 16 is clicked.
- Steps:
- Opens a form named "14" + Chr$(34) + " Process Sheet" and sets its record source to the "Processes by List" query.
- Exits the subroutine.
Command18_Click
- Purpose: This subroutine is triggered when another button with ID 18 is clicked.
- Steps:
- Opens a query named "Filtered Parts 2" in normal view, displaying the filtered parts data.
- Updates the status message to indicate readiness for the next action.
Command20_Click
- Purpose: This subroutine is triggered when another button with ID 20 is clicked.
- Steps:
- Opens a table named "Filtered Parts" in normal view, allowing users to modify it before proceeding.
- Updates the status message to remind users to modify queries before running parts.
Command22_Click
- Purpose: This subroutine is triggered when another button with ID 22 is clicked.
- Steps:
- Opens a query named "Filtered Parts 4" in normal view, displaying data ready for processing through AS-400.
- Updates the status message to indicate readiness for further actions.
Command23_Click
- Purpose: This subroutine is triggered when another button with ID 23 is clicked.
- Steps:
- Opens a query named "Filtered Parts 3" in normal view, displaying data.
Command24_Click
- Purpose: This subroutine is triggered when another button with ID 24 is clicked.
- Steps:
- Opens a query named "Filtered Parts 3" in design view, allowing users to modify the query further before running parts through AS-400.
- Updates the status message to indicate readiness for final checks.
Key Features and Functions
- Database management and Recordset creation
- Data purging and processing
- Form opening and record source setting
- Query opening in normal and design views
Error Handling
The code includes error handling mechanisms, such as On Error Resume Next
and On Error GoTo Err_CommandName_Click
, to catch and display error messages.