L
lulugrant_is_a_dog
I am trying to turn columns on an off in a report by using checkboxes
on another form (called frmAdvancedSearch). The code below is run when
the report is opened. I have named everything with numbers (chk1, chk2,
txt1, txt2 etc.) so that I can use a loop and save myself from writing
a lot of code.
--------------------------------------------
Private Sub Report_Open(Cancel As Integer)
'position of column on report
Dim position As Long
'name of check box on frmAdvancedSearch
Dim chkno As Object
position = 0.68
For K = 1 To 16
Set chkno = "chk" & K
If Forms![frmAdvancedSearch]![chkno] = True Then
Me("txt" & K).Left = position
Me("txt" & K).Visible = True
Me("lbl" & K).Left = position
Me("lbl" & K).Visible = True
position = position + Me("txt" & K).Width
End If
Next K
End Sub
--------------------------------------------------
The code doesn't work thought, and I think it has something to do with
the way I have addressed the checkboxes on the form. When the report
opens an error is displayed that says "Object Required".
Debug points me to the line "Set chkno = "chk" & K"
I am not very experienced with this and any help would be greatly
appreciated.
on another form (called frmAdvancedSearch). The code below is run when
the report is opened. I have named everything with numbers (chk1, chk2,
txt1, txt2 etc.) so that I can use a loop and save myself from writing
a lot of code.
--------------------------------------------
Private Sub Report_Open(Cancel As Integer)
'position of column on report
Dim position As Long
'name of check box on frmAdvancedSearch
Dim chkno As Object
position = 0.68
For K = 1 To 16
Set chkno = "chk" & K
If Forms![frmAdvancedSearch]![chkno] = True Then
Me("txt" & K).Left = position
Me("txt" & K).Visible = True
Me("lbl" & K).Left = position
Me("lbl" & K).Visible = True
position = position + Me("txt" & K).Width
End If
Next K
End Sub
--------------------------------------------------
The code doesn't work thought, and I think it has something to do with
the way I have addressed the checkboxes on the form. When the report
opens an error is displayed that says "Object Required".
Debug points me to the line "Set chkno = "chk" & K"
I am not very experienced with this and any help would be greatly
appreciated.