Hard to put a name question

V

Veli Izzet

Hi all,

I have a report where there are lots of controls with IIF's all pointing
to a Form1 ( Like IIF (Forms!Form1!ctlControl=, etc etc).

Now I want them to all point out to Form2. Is there a way to change them
at once like a search-reply function, or do I have to write them all one
by one.

TIA
 
W

Wayne Morgan

The real question is why are you changing them? Are you developing multiple
reports by copying a report you already have? Could you instead, just use
code to change the desired boxes when you open the report?

If you do want to change the control source and save it that way in the
report, you could use code to open the report in design mode, have it
enumerate through the controls, check their control source property for the
desired string and, if found, use the Replace function to change it, then
close and save the changes.

Example:
Dim ctl As Control, strReportName As String
strReportName = "rptReportName"
DoCmd.OpenReport strReportName,acViewDesign,,,acHidden
For Each ctl In Reports(strReportName).Controls
If InStr(ctl.ControlSource, "Forms!Form1") > 0 Then
ctl.ControlSource = Replace(ctl.ControlSource, "Forms!Form1",
"Forms!Form2")
End If
Next
DoCmd.Close acReport, strReportName, acSaveYes
 
V

Veli Izzet

Wayne,

Sometimes a quick-and-dirty approach proves to be better than an elegant
one. Mostly when you are pressed for time. That is the reason I copied
the report instead of writing code. BTW, I am not proficient at writing
code as much as I like.

Thanks for your help.
 
Top