PDA

Click to See Complete Forum and Search --> : Make changes to a report's control from a form <Self-solved>


jute
Jul 23rd, 2003, 09:47 PM
In M$ Access, say I have a simple user input form, a table that stores data on the form and a ready-made report that consists of hundreds of textboxes that contain table data and hundreds of labels that are just, well, plain labels.

On the form, there are several data fields and a huge "Print" button that will open the report for preview as well as print.

Now the problem is, I have to add a checkbox that, when checked, some of those labels on that report will not be printed. How do I control that from the form?

I know I could just create another report without those labels to achieve this purpose but is there a way I can modify report controls from a userform?

jute
Jul 24th, 2003, 12:38 AM
Ok I found out how to do it by declaring a public variable in the Modules section then read from that variable in the Report_Open event.

Now I ran into another problem. Since there are a total of 188 labels to work with, I can't do it one by one. So I wrote this code in the Report_Open:
Dim Ctrl As Label
For Each Ctrl In Me
If Ctrl.Caption Like "-*" Then Ctrl.Visible = ShowFlag 'ShowFlag is the public variable (boolean)
Next Ctrl
With this code there, however, the report won't open except in design mode. No error messages, just can't preview and can't print.

Anything wrong? :confused:

jute
Jul 24th, 2003, 09:13 AM
Never mind...I got it working. :p