OK,
So I have some VBA code that helps format my report. In the PageHeader I have a bunch of checkboxes, and depending on what is in the Detail section of my report determines what checkboxes are or aren't checked.
When I run the Report in debug mode in the VBA editor, the report works fine, but if I just run the report like I regularly would, the checkboxes don't get checked/unchecked properly.
Any ideas??
Here is my code:
Option Compare Database
Dim resetBoxes As Boolean
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If resetBoxes = False Then
chk1y = False
chk1n = True
chk2y = False
chk2n = True
chk3y = False
chk3n = True
chk4y = False
chk4n = True
chk5y = False
chk5n = True
chk6y = False
chk6n = True
chk7y = False
chk7n = True
chk8y = False
chk8n = True
chk9y = False
chk9n = True
chk10y = False
chk10n = True
chk11y = False
chk11n = True
chk12y = False
chk12n = True
chk13y = False
chk13n = True
chk14y = False
chk14n = True
chk15y = False
chk15n = True
chk16y = False
chk16n = True
chk17y = False
chk17n = True
chk18y = False
chk18n = True
chk19y = False
chk19n = True
chk20y = False
chk20n = True
chk21y = False
chk21n = True
chk22y = False
chk22n = True
chk23y = False
chk23n = True
chk24y = False
chk24n = True
chk25y = False
chk25n = True
chk26y = False
chk26n = True
chk27y = False
chk27n = True
chk28y = False
chk28n = True
chk29y = False
chk29n = True
chk30y = False
chk30n = True
chk31y = False
chk31n = True
resetBoxes = True
End If
Call AlternateGray
Select Case DESCR
Case "Surface Potholes"
chk1y = True
chk1n = False
Case "Surface Dust/Dirt"
chk2y = True
chk2n = False
Case "Surface Cracks"
chk3y = True
chk3n = False
Case "Surface Discontinuities"
chk4y = True
chk4n = False
Case "Bridge Deck Spalling"
chk5y = True
chk5n = False
Case "Shoulder Potholes/Washouts"
chk6y = True
chk6n = False
Case "Grading/Drop Offs"
chk7y = True
chk7n = False
Case "Shoulder Dust/Dirt"
chk8y = True
chk8n = False
Case "Sod Removal"
chk9y = True
chk9n = False
Case "Tall Grass - Mowing"
chk10y = True
chk10n = False
Case "Tree/Branch Removal"
chk11y = True
chk11n = False
Case "Weed Control"
chk12y = True
chk12n = False
Case "Litter Removal"
chk13y = True
chk13n = False
Case "Ditching - Salt/Debris"
chk14y = True
chk14n = False
Case "Culvert Cleaning"
chk15y = True
chk15n = False
Case "Entrance/Culvert/Repair"
chk16y = True
chk16n = False
Case "Bridge Cleaning"
chk17y = True
chk17n = False
Case "Subsurface Blockages"
chk18y = True
chk18n = False
Case "Catchbasins"
chk19y = True
chk19n = False
Case "Signs"
chk20y = True
chk20n = False
Case "R.R. Crossing Signals"
chk21y = True
chk21n = False
Case "Signals"
chk22y = True
chk22n = False
Case "Guide Posts"
chk23y = True
chk23n = False
Case "Pavement Markings"
chk24y = True
chk24n = False
Case "Dead Trees"
chk25y = True
chk25n = False
Case "Illegal Signs"
chk26y = True
chk26n = False
Case "Utility Cuts"
chk27y = True
chk27n = False
Case "Material Dumping"
chk28y = True
chk28n = False
Case "Bldg. too Close to Road"
chk29y = True
chk29n = False
Case "Permits for Driveway Access or Paving"
chk30y = True
chk30n = False
Case "Other Defects"
chk31y = True
chk31n = False
End Select
End Sub
Private Sub AlternateGray()
'this will alternate the color of the background for the Detail between white and gray
If Me.Section(0).BackColor = 16777215 Then
Me.Section(0).BackColor = 15724527
DESCR.BackColor = 15724527
DETAILS.BackColor = 15724527
ACTIONTAKEN.BackColor = 15724527
Else
Me.Section(0).BackColor = 16777215
DESCR.BackColor = 16777215
DETAILS.BackColor = 16777215
ACTIONTAKEN.BackColor = 16777215
End If
End Sub
So I have some VBA code that helps format my report. In the PageHeader I have a bunch of checkboxes, and depending on what is in the Detail section of my report determines what checkboxes are or aren't checked.
When I run the Report in debug mode in the VBA editor, the report works fine, but if I just run the report like I regularly would, the checkboxes don't get checked/unchecked properly.
Any ideas??
Here is my code:
Option Compare Database
Dim resetBoxes As Boolean
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If resetBoxes = False Then
chk1y = False
chk1n = True
chk2y = False
chk2n = True
chk3y = False
chk3n = True
chk4y = False
chk4n = True
chk5y = False
chk5n = True
chk6y = False
chk6n = True
chk7y = False
chk7n = True
chk8y = False
chk8n = True
chk9y = False
chk9n = True
chk10y = False
chk10n = True
chk11y = False
chk11n = True
chk12y = False
chk12n = True
chk13y = False
chk13n = True
chk14y = False
chk14n = True
chk15y = False
chk15n = True
chk16y = False
chk16n = True
chk17y = False
chk17n = True
chk18y = False
chk18n = True
chk19y = False
chk19n = True
chk20y = False
chk20n = True
chk21y = False
chk21n = True
chk22y = False
chk22n = True
chk23y = False
chk23n = True
chk24y = False
chk24n = True
chk25y = False
chk25n = True
chk26y = False
chk26n = True
chk27y = False
chk27n = True
chk28y = False
chk28n = True
chk29y = False
chk29n = True
chk30y = False
chk30n = True
chk31y = False
chk31n = True
resetBoxes = True
End If
Call AlternateGray
Select Case DESCR
Case "Surface Potholes"
chk1y = True
chk1n = False
Case "Surface Dust/Dirt"
chk2y = True
chk2n = False
Case "Surface Cracks"
chk3y = True
chk3n = False
Case "Surface Discontinuities"
chk4y = True
chk4n = False
Case "Bridge Deck Spalling"
chk5y = True
chk5n = False
Case "Shoulder Potholes/Washouts"
chk6y = True
chk6n = False
Case "Grading/Drop Offs"
chk7y = True
chk7n = False
Case "Shoulder Dust/Dirt"
chk8y = True
chk8n = False
Case "Sod Removal"
chk9y = True
chk9n = False
Case "Tall Grass - Mowing"
chk10y = True
chk10n = False
Case "Tree/Branch Removal"
chk11y = True
chk11n = False
Case "Weed Control"
chk12y = True
chk12n = False
Case "Litter Removal"
chk13y = True
chk13n = False
Case "Ditching - Salt/Debris"
chk14y = True
chk14n = False
Case "Culvert Cleaning"
chk15y = True
chk15n = False
Case "Entrance/Culvert/Repair"
chk16y = True
chk16n = False
Case "Bridge Cleaning"
chk17y = True
chk17n = False
Case "Subsurface Blockages"
chk18y = True
chk18n = False
Case "Catchbasins"
chk19y = True
chk19n = False
Case "Signs"
chk20y = True
chk20n = False
Case "R.R. Crossing Signals"
chk21y = True
chk21n = False
Case "Signals"
chk22y = True
chk22n = False
Case "Guide Posts"
chk23y = True
chk23n = False
Case "Pavement Markings"
chk24y = True
chk24n = False
Case "Dead Trees"
chk25y = True
chk25n = False
Case "Illegal Signs"
chk26y = True
chk26n = False
Case "Utility Cuts"
chk27y = True
chk27n = False
Case "Material Dumping"
chk28y = True
chk28n = False
Case "Bldg. too Close to Road"
chk29y = True
chk29n = False
Case "Permits for Driveway Access or Paving"
chk30y = True
chk30n = False
Case "Other Defects"
chk31y = True
chk31n = False
End Select
End Sub
Private Sub AlternateGray()
'this will alternate the color of the background for the Detail between white and gray
If Me.Section(0).BackColor = 16777215 Then
Me.Section(0).BackColor = 15724527
DESCR.BackColor = 15724527
DETAILS.BackColor = 15724527
ACTIONTAKEN.BackColor = 15724527
Else
Me.Section(0).BackColor = 16777215
DESCR.BackColor = 16777215
DETAILS.BackColor = 16777215
ACTIONTAKEN.BackColor = 16777215
End If
End Sub