PSLine2000Documentation/Forms/Phantom Selection Screen.md

2.7 KiB

Phantom Selection Screen

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

Record Source

  • None

Controls

Control Name Reference
None -

VBA Code

Option Compare Database   'Use database order for string comparisons

Private Sub Button2_Click()
   Call ckPrimaryScreen
   ErrM.Caption = ""
   Mater$ = itsaNull$(Phantom)
   If Mater$ <> "" Then
      DoCmd.OpenForm PrimaryScreen$, , , "PhantomNumber=" + Chr$(34) + Mater$ + Chr$(34)
   Else
      ErrM.Caption = "Invalid Material Selected"
   End If
End Sub

Private Sub Button6_Click()
   ErrM.Caption = ""
   Mater$ = itsaNull$(Material)
   If Mater$ <> "" Then
      DoCmd.OpenReport "RSelectMaterial", A_PREVIEW, , "MetalType=" + Chr$(34) + Mater$ + Chr$(34)
   Else
      ErrM.Caption = "Invalid Material Selected"
   End If
End Sub

What it does

Code Description

This VBA code snippet appears to be part of an Access database application. It defines two event handlers for button clicks: Button2_Click and Button6_Click.

Button2_Click

**Button2_Click Event Handler**
  • When the button with ID Button2 is clicked, this subroutine is executed.
  • The first line calls the ckPrimaryScreen procedure (not shown in the code snippet).
  • It then clears any error message associated with ErrM.
  • The value of Material (Mater) is checked for null using the itsaNull$( ) function. If it's not null, a specific material number is used.
  • Based on the presence or absence of a valid material number, two different actions are taken:
    • If a valid material number is available, it opens a form named PrimaryScreen with the material number as a parameter.
    • Otherwise, an error message "Invalid Material Selected" is displayed.

Button6_Click

**Button6_Click Event Handler**
  • Similar to Button2_Click, when the button with ID Button6 is clicked, this subroutine is executed.
  • It clears any existing error message in ErrM.
  • The value of Material (Mater) is checked for null using the itsaNull$( ) function. If it's not null, a specific metal type is used.
  • Based on the presence or absence of a valid material number, this action:
    • Opens a report named RSelectMaterial with the metal type as a parameter and preview mode enabled.
    • Otherwise, an error message "Invalid Material Selected" is displayed.

Key Observations:

  • The code uses Access database-specific functions like DoCmd.OpenForm, DoCmd.OpenReport, and ErrM.Caption.
  • It employs string concatenation using the $ symbol to build parameters for form and report openings.
  • Error handling and material validation mechanisms ensure that only valid inputs are used in subsequent operations.