Hard to put a name question

  • Thread starter Thread starter Veli Izzet
  • Start date Start date
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
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top