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:
- Opens the database and creates a dynamic recordset named "Util L X W".
- Sets various global variables (
BGW!
,EDW!
,ICW!
,BGL!
,EDL!
, andICL!
) to define the range of sheet widths, lengths, and incremental values. - Loops through all possible combinations of sheet widths (from
BGW!
toEDW!
with an increment ofICW!
) and lengths (fromBGL!
toEDL!
with an increment ofICL!
). - For each combination, creates a new record in the dynamic recordset with the corresponding sheet width and length.
- Updates the dynaset to reflect the changes.
cmdLengths_Click Subroutine
Purpose: Update global variables for sheet lengths based on user input.
Description:
- Sets the global variable
SheetWidths!
to the value of the "Add Widths" field. - Calls the
Addparms
subroutine withi% = 2
andSheetWidths!
as arguments. - This sets up the dynaset for sheet widths.
cmdWidths_Click Subroutine
Purpose: Update global variables for sheet lengths based on user input.
Description:
- Sets the global variable
SheetLength!
to the value of the "Add Lengths" field. - Calls the
Addparms
subroutine withi% = 1
andSheetLength!
as arguments. - 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:
- Opens the database and creates a dynamic recordset named "Util L X W".
- Sets various global variables (
BG!
,ed!
, andIC!
) to define the range of sheet widths, lengths, and incremental values based on the value ofi%
. - Loops through all possible combinations of sheet widths (from
BG!
toed!
with an increment ofIC!
) and lengths (fromBGL!
toEDL!
with an increment ofICL!
). - For each combination, sets the global variables
SheetWidths!
andSheetLength!
accordingly. - 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.