create event to display label only

S

Sylvie

I have a form that has 2 tabs, one tab named Details and the other one named
DG Status. On the DG Status tab, there is a check box named DG1Approval, when
the check box is selected, the DG1 label on the Detail tab would appear. If
not checked, it won't be visible. Not sure how to do that?
Any help would be greatly appreciated. thank you
 
D

Damon Heron

Not sure whether you want to make the tab itself not visible or just change
the caption?
In the click event of the checkbox here is both:

Private Sub DG1Approval_Click()
If Me.DG1Approval Then
Me.Details.Visible = True
Me.Details.Caption = "DG1"
Else
Me.Details.Visible = False 'if you want the tab not visible
' or (if you just want the label to change): Me.Details.Caption = " "
End If
End Sub

Damon
 
K

Ken Sheridan

If the DHG1 label is a label control on page 1 of the tab control then in the
check box's AfterUpdate event procedure put:

Me.[DG1 Label].Visible = Me.[DG1Approval]

where DG1 Label is the name of the label control. If the form is a bound
one and the check box is bound to a field in the underlying table or query
then put the same line of code in the form's Current event procedure.

Ken Sheridan
Stafford, England
 
S

Sylvie

Thank you Ken. this works great. One more question, i have 3 labels that need
to flag. dg1, dg2, dg3. I wrote the same code in their respective check
boxes' afterUpdate, works fine but what should i put in the form's current
event procedure.
If i write the same codes entered in the AfterUpdate, it generates an error:
"Run-time error 94 - invalid use of Null". It works fine with one code but
not with the three of them. This is for i entered in the form's current event
procedure
Me.[DG1 label].visible = me.[DG1Approval]
Me.[DG2 label].visible = me.[DG2Approval]
me.[DG3 label].visible = me.[DG3Approval]

I know i must be doing something wrong. Thanks for your help.



Ken Sheridan said:
If the DHG1 label is a label control on page 1 of the tab control then in the
check box's AfterUpdate event procedure put:

Me.[DG1 Label].Visible = Me.[DG1Approval]

where DG1 Label is the name of the label control. If the form is a bound
one and the check box is bound to a field in the underlying table or query
then put the same line of code in the form's Current event procedure.

Ken Sheridan
Stafford, England

Sylvie said:
I have a form that has 2 tabs, one tab named Details and the other one named
DG Status. On the DG Status tab, there is a check box named DG1Approval, when
the check box is selected, the DG1 label on the Detail tab would appear. If
not checked, it won't be visible. Not sure how to do that?
Any help would be greatly appreciated. thank you
 
K

Ken Sheridan

Even with a bound check box it will be Null when you first navigate to a new
record. Only when you begin to enter data will its value become False.
There are various ways you can handle this. If they are bound controls one
would be to set the underlying fields' and the check boxes' DefaultValue
properties to False in table and form design view. Another, which should
work whether the controls are bound or not, would be to amend the code, using
the Nz function to return False if the control is Null:

Me.[DG1 label].visible = Nz(Me.[DG1Approval],False)
Me.[DG2 label].visible = Nz(Me.[DG2Approval],False)
Me.[DG3 label].visible = Nz(Me.[DG3Approval],False)

Ken Sheridan
Stafford, England

Sylvie said:
Thank you Ken. this works great. One more question, i have 3 labels that need
to flag. dg1, dg2, dg3. I wrote the same code in their respective check
boxes' afterUpdate, works fine but what should i put in the form's current
event procedure.
If i write the same codes entered in the AfterUpdate, it generates an error:
"Run-time error 94 - invalid use of Null". It works fine with one code but
not with the three of them. This is for i entered in the form's current event
procedure
Me.[DG1 label].visible = me.[DG1Approval]
Me.[DG2 label].visible = me.[DG2Approval]
me.[DG3 label].visible = me.[DG3Approval]

I know i must be doing something wrong. Thanks for your help.



Ken Sheridan said:
If the DHG1 label is a label control on page 1 of the tab control then in the
check box's AfterUpdate event procedure put:

Me.[DG1 Label].Visible = Me.[DG1Approval]

where DG1 Label is the name of the label control. If the form is a bound
one and the check box is bound to a field in the underlying table or query
then put the same line of code in the form's Current event procedure.

Ken Sheridan
Stafford, England

Sylvie said:
I have a form that has 2 tabs, one tab named Details and the other one named
DG Status. On the DG Status tab, there is a check box named DG1Approval, when
the check box is selected, the DG1 label on the Detail tab would appear. If
not checked, it won't be visible. Not sure how to do that?
Any help would be greatly appreciated. thank you
 

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