How do I hide & show a label in a report using a toggle button in a form

F

FrunkaBlunka

Does anybody know how to hide & show a label in a report using a toggle
button in a form?

What I am trying to achieve is displaying some text on a label in a
report (like applying a stamp to the report) when a toggle button in my
main form is pressed down. When it is in the upstate I want the lable
to be invisible on the report.

How do I achieve this?

Please :)

My form is called frmProject
My report is called rptJobOverview
My toggle button in frmProject is called tgbTrack
My label in rptJobOverview is called lbltrack

Thanks
 
J

John Spencer

I just replied to your earlier post with a proposed solution.

Please be patient. These groups are manned by volunteers and it often takes
as much as a day (sometimes more) to get a response to a posting.
 
T

tina

a toggle button that is running by itself (not as part of an option group)
returns a value of True (-1) when it is depressed, and False (0) when it is
un-depressed, and a value of Null before the first time it is depressed
after the form is opened. try adding the following code to the Print event
procedure of *the section of the report that the label sits in*, as

Me!lbltrack.Visible = Nz(Forms!frmProject!tgbTrack, False)

or, you might put the value of tgbTrack in the OpenArgs argument of the
OpenForm command, and refer to that - on your form, in the code that opens
the report, as

DoCmd.OpenReport "rptJobOverview", acViewPreview, _
, , , Nz(Me!tgbTrack, 0)

(if you're printing the report, rather than previewing it, remove the
acViewPreview argument of course, but not the commas) and change the code in
the report section's Print event procedure to

Me!lbltrack.Visible = Me.OpenArgs

personally, i would probably use the second solution; i prefer not to refer
to "outside" objects in my code, if i don't have to.

hth
 
T

tina

man, i hate when that happens - i had better things to do than work on a
question that was already answered!
 
D

Douglas J Steele

Where is the label: in the report's Detail section, or in one of the Header
or Footer sections?

In the Format event of whatever section the label's in, try the following:

Me.lbltrack.Visible = Forms!frmProject!tgbTrack
 
F

FrunkaBlunka

Hi guys,

Sorry about the double post. As you can tell I am novice at this.
Thanks for all your assistance I almost have it working using this code
which you provided me with...

Private Sub Report_Activate()
Me!lblTrack.Visible = Nz(Forms!frmProject!tgbTrack, False)
End Sub

This code seemed to work for me... when the toggle button is in the
down state it appears and when it is in its upstate it disappears which
is excatly what I want.. There is just one problem it places the
"stamp" on all my records in the report instead of just the ones that
have the toggle button in the down state.

Do I have to direct my code to the table where it stores the value of
the toggle button of each record. The name of the table is tblProject
and the column is called Track Installed.
I tried to do this but I couldnt get it to work.

Thanks again for your help
 
F

FrunkaBlunka

The rpeorts detailed section

Thanks
Where is the label: in the report's Detail section, or in one of the Header
or Footer sections?

In the Format event of whatever section the label's in, try the following:

Me.lbltrack.Visible = Forms!frmProject!tgbTrack
 
J

John Spencer

Now that you have given us further details, lets revise the answer

Do I have to direct my code to the table where it stores the value of
the toggle button of each record. The name of the table is tblProject
and the column is called Track Installed.
I tried to do this but I couldnt get it to work.

Make sure you have a reference to the column [track Installed] in the
report's source.
Include a control on your report in the detail section that is bound
(control source) to [Track Installed].
You can set this control's visible property to No (False).
Name the control something like txtTrackInstalled

In the On Format event of your report's detail event you can then use
something like the following.

If txtTrackInstalled = True Then
Me.lblTrack.Visible = True
Else
Me.lblTrack.Visible = False
End If


Or even shorter, but a bit harder to understand
Me.lblTrack.Visible = txtTrackInstalled

If that shows the label when you wish it hidden then modify it to
Me.lblTrack.Visible = NOT( txtTrackInstalled)
 
F

FrunkaBlunka

Hi,

Thanks for your help John, it works perfectly now. I wish I found these
forums earlier.

;)

John said:
Now that you have given us further details, lets revise the answer

Do I have to direct my code to the table where it stores the value of
the toggle button of each record. The name of the table is tblProject
and the column is called Track Installed.
I tried to do this but I couldnt get it to work.

Make sure you have a reference to the column [track Installed] in the
report's source.
Include a control on your report in the detail section that is bound
(control source) to [Track Installed].
You can set this control's visible property to No (False).
Name the control something like txtTrackInstalled

In the On Format event of your report's detail event you can then use
something like the following.

If txtTrackInstalled = True Then
Me.lblTrack.Visible = True
Else
Me.lblTrack.Visible = False
End If


Or even shorter, but a bit harder to understand
Me.lblTrack.Visible = txtTrackInstalled

If that shows the label when you wish it hidden then modify it to
Me.lblTrack.Visible = NOT( txtTrackInstalled)


John Spencer said:
I just replied to your earlier post with a proposed solution.

Please be patient. These groups are manned by volunteers and it often
takes as much as a day (sometimes more) to get a response to a posting.
 

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

Top