PSLine2000Documentation/Forms/Util Adder.md

4.3 KiB

Util Adder

Analysis generated on: 4/1/2025 4:04:28 PM

Record Source

  • None

Controls

Control Name Reference
None -

VBA Code

Option Compare Database

Private Sub cmdCreate_Click()
   Dim MainDB As Database, MainSet As Recordset
   Set MainDB = DBEngine.Workspaces(0).Databases(0)
   Set MainSet = MainDB.OpenRecordset("Util L X W")   ' Create dynaset.
   
   BGW! = BegWidth
   EDW! = EndWidth
   ICW! = IncWidth
   
   BGL! = BegLength
   EDL! = EndLength
   ICL! = IncLength
   
   For Sheet_Width! = BGW! To EDW! Step ICW!
      For Sheet_Length! = BGL! To EDL! Step ICL!
        
         MainSet.AddNew
         MainSet!SheetL = Sheet_Length!
         MainSet!sheetw = Sheet_Width!
         MainSet.Update
      Next
   Next
   
End Sub

Private Sub cmdLengths_Click()
   SheetWidths! = Val(AddWidths)
   Call Addparms(2, SheetWidths!)
End Sub

Private Sub cmdWidths_Click()
   SheetLength! = Val(AddLengths)
   Call Addparms(1, SheetLength!)
End Sub

Private Sub Addparms(i%, Sizeses!)
   Dim MainDB As Database, MainSet As Recordset
   Set MainDB = DBEngine.Workspaces(0).Databases(0)
   Set MainSet = MainDB.OpenRecordset("Util L X W")   ' Create dynaset.
   
   BGW! = BegWidth
   EDW! = EndWidth
   ICW! = IncWidth
   
   BGL! = BegLength
   EDL! = EndLength
   ICL! = IncLength
   
   If i% = 1 Then
      BG! = BegWidth
      ed! = EndWidth
      IC! = IncWidth
   Else
      BG! = BegLength
      ed! = EndLength
      IC! = IncLength
   End If
   
   For SS! = BG! To ed! Step IC!
      If i% = 1 Then
         SheetWidth! = SS!
         SheetLength! = Sizeses!
      Else
         SheetWidth! = Sizeses!
         SheetLength! = SS!
      End If
         
      MainSet.AddNew
      MainSet!SheetL = SheetLength!
      MainSet!sheetw = SheetWidth!
      MainSet.Update
   Next
   
End Sub

What it does

VBA Code Description

This VBA code is written in an Access database and appears to be part of a larger application for managing sheet sizes. The code consists of three main subroutines: cmdCreate, cmdLengths, and cmdWidths.

cmdCreate_Click Subroutine

Purpose: Create new records in the "Util L X W" dynaset with specified sheet widths and lengths.

Description:

  1. Opens the database and creates a dynamic recordset named "Util L X W".
  2. Sets various global variables (BGW!, EDW!, ICW!, BGL!, EDL!, and ICL!) to define the range of sheet widths, lengths, and incremental values.
  3. Loops through all possible combinations of sheet widths (from BGW! to EDW! with an increment of ICW!) and lengths (from BGL! to EDL! with an increment of ICL!).
  4. For each combination, creates a new record in the dynamic recordset with the corresponding sheet width and length.
  5. Updates the dynaset to reflect the changes.

cmdLengths_Click Subroutine

Purpose: Update global variables for sheet lengths based on user input.

Description:

  1. Sets the global variable SheetWidths! to the value of the "Add Widths" field.
  2. Calls the Addparms subroutine with i% = 2 and SheetWidths! as arguments.
  3. This sets up the dynaset for sheet widths.

cmdWidths_Click Subroutine

Purpose: Update global variables for sheet lengths based on user input.

Description:

  1. Sets the global variable SheetLength! to the value of the "Add Lengths" field.
  2. Calls the Addparms subroutine with i% = 1 and SheetLength! as arguments.
  3. This sets up the dynaset for sheet lengths.

Addparms Subroutine

Purpose: Updates global variables for sheet dimensions based on user input and dynaset configuration.

Description:

  1. Opens the database and creates a dynamic recordset named "Util L X W".
  2. Sets various global variables (BG!, ed!, and IC!) to define the range of sheet widths, lengths, and incremental values based on the value of i%.
  3. Loops through all possible combinations of sheet widths (from BG! to ed! with an increment of IC!) and lengths (from BGL! to EDL! with an increment of ICL!).
  4. For each combination, sets the global variables SheetWidths! and SheetLength! accordingly.
  5. Updates the dynaset to reflect the changes.

Note: The code uses global variables (BGW!, EDW!, ICW!, BGL!, EDL!, ICL!, etc.) which may not be suitable for large-scale applications or production environments.