PSLine2000Documentation/Forms/Filtered Parts old.md

6.8 KiB

Filtered Parts old

Analysis generated on: 4/1/2025 4:09:40 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$
         MainSet.Update
         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 consists of several subroutines that perform various tasks related to data manipulation, querying, and reporting.

Command13_Click Subroutine


This subroutine is triggered when a button with the label "Command 13" is clicked. The code performs the following actions:

  1. Sets up Database: Sets up two databases (MainDB and MainDB2) using the currently active workspace.
  2. Purges AS400 product number file: Deletes all records from the RMSFILES#_IEMUP1A0 recordset in MainDB.
  3. Moves parts to AS400: Iterates through the records in the Filtered Parts recordset in MainDB2, adds each record to the corresponding recordset in MainDB, and updates the database.
  4. Activates AS400 Program: Activates an XLCtl24 button, which likely triggers some external program or task.
  5. Puts parts in 'Process By List' Table: Opens a query named "Filtered Parts 4" in edit mode.

Command16_Click Subroutine


This subroutine is triggered when another button with the label "Command 16" is clicked. The code:

  1. Opens Process Sheet form: Opens a form named "14 Process Sheet" and sets its record source to "Processes by List".
  2. Error handling: Catches any errors that occur during execution and displays an error message.

Command18_Click Subroutine


This subroutine is triggered when yet another button with the label "Command 18" is clicked. The code:

  1. Opens Filtered Parts query: Opens a query named "Filtered Parts 2" in edit mode.
  2. Updates status label: Sets the caption of a label (lblstatus) to indicate that the process is complete.

Command20_Click Subroutine


This subroutine is triggered when a button with the label "Command 20" is clicked. The code:

  1. Opens Filtered Parts table view: Opens a table named "Filtered Parts" in view mode.
  2. Updates status label: Sets the caption of a label (lblstatus) to indicate that the process is complete.

Command22_Click Subroutine


This subroutine is triggered when a button with the label "Command 22" is clicked. The code:

  1. Opens Filtered Parts query in design mode: Opens a query named "Filtered Parts 4" in design view.
  2. Updates status label: Sets the caption of a label (lblstatus) to indicate that the process is complete.

Command23_Click Subroutine


This subroutine is triggered when a button with the label "Command 23" is clicked. The code:

  1. Opens Filtered Parts query in normal view: Opens a query named "Filtered Parts 3" in normal view.
  2. Does nothing else (yet)

Command24_Click Subroutine


This subroutine is triggered when a button with the label "Command 24" is clicked. The code:

  1. Opens Filtered Parts query in design mode: Opens a query named "Filtered Parts 3" in design view.
  2. Updates status label: Sets the caption of a label (lblstatus) to indicate that the process is complete.

Common Elements

Throughout these subroutines, there are several common elements:

  • The use of DoEvents statements to ensure proper processing and prevent blocking.
  • Error handling using On Error Resume Next and On Error GoTo Err_CommandSubroutine, which catch any errors that occur during execution and display an error message.

Conclusion

This VBA code provides a basic framework for interacting with databases, querying data, and updating records. While it may require modification or extension to meet specific requirements, its structure and functionality provide a solid foundation for further development.