B
Brian
I have the following code in a module. I am trying to
delete controls on a report in design mode that are needed
when a particular report needs to be printed. I make a
copy of the report and then open the report in design
mode. I would like to delete all of the elements (text
boxes, labels) in the report that begin with names
like "xxx". I have cutoff the 1st 4 characters of each
element. When I run the code, it only deletes 3 out of
about 10 in needs to delete. What's going on.
here is a the code.
DoCmd.DeleteObject acReport, "zztest"
DoCmd.CopyObject , "zzTest",
acReport, "rptStats_PatientsServed_Join"
DoCmd.OpenReport "zztest", acViewDesign
Dim rpt As Report
Dim ctl As Control
Set rpt = Screen.ActiveReport
Dim thing As String
Set ctl = Nothing
For Each ctl In rpt.Controls
Debug.Print "CONTROL NAME: "; ctl.name
thing = Mid(ctl.name, 1, 4)
Debug.Print "THING: "; thing
If thing = "grp3" Then
DeleteReportControl "zztest", ctl.name
End If
Next
Set ctl = Nothing
delete controls on a report in design mode that are needed
when a particular report needs to be printed. I make a
copy of the report and then open the report in design
mode. I would like to delete all of the elements (text
boxes, labels) in the report that begin with names
like "xxx". I have cutoff the 1st 4 characters of each
element. When I run the code, it only deletes 3 out of
about 10 in needs to delete. What's going on.
here is a the code.
DoCmd.DeleteObject acReport, "zztest"
DoCmd.CopyObject , "zzTest",
acReport, "rptStats_PatientsServed_Join"
DoCmd.OpenReport "zztest", acViewDesign
Dim rpt As Report
Dim ctl As Control
Set rpt = Screen.ActiveReport
Dim thing As String
Set ctl = Nothing
For Each ctl In rpt.Controls
Debug.Print "CONTROL NAME: "; ctl.name
thing = Mid(ctl.name, 1, 4)
Debug.Print "THING: "; thing
If thing = "grp3" Then
DeleteReportControl "zztest", ctl.name
End If
Next
Set ctl = Nothing