Programmatically make a label permanently visible

S

Silvio

I am using the code below to make a label visible located in Form1 from Form2
(They are two separate forms not in a subform relation). The code works fine
as long the database runs. However, if I restart it, then the label goes back
to visible = False. I need it to remain Visible = True weather you restart
the database or not. I know I can go to the Form1 and change the property of
the label to visible = True, however it is important that is done
programmatically.

Forms![frmWelcome]![lblTestMode].Visible = False

Thanks,
Silvio
 
F

fredg

I am using the code below to make a label visible located in Form1 from Form2
(They are two separate forms not in a subform relation). The code works fine
as long the database runs. However, if I restart it, then the label goes back
to visible = False. I need it to remain Visible = True weather you restart
the database or not. I know I can go to the Form1 and change the property of
the label to visible = True, however it is important that is done
programmatically.

Forms![frmWelcome]![lblTestMode].Visible = False

Thanks,
Silvio

To have the form retain the changed setting you must first open it in
Design View, change the setting and then Save it.

Using code from Form2:

Private SomeEvent()
DoCmd.OpenForm "frmWelcome", acDesign, , , , acHidden
Forms!frWelcome!lblTestMode.Visible = True
DoCmd.Close acForm, "frmWelcome", acSaveYes

' you can then re-open the form in Form View ... or not.
DoCmd.OpenForm "frmWelcome"

End Sub
 
C

channell

Try This under the Form Load Property:

Private Sub Form_Load()
Me.lblTestMode.Visible=True
End Sub

This way, every time the form is Loaded (or opened), the label is always
displayed.

-Scott Channell
 
S

Silvio

Fred, the frmWecome is always open and needs to stay that way for several
reasons. Do you know of a way to just change the normal view to design view,
make the change to the label, save the form (without closing it) and switch
back to normal view?
 
D

Dirk Goldgar

Silvio said:
Fred, the frmWecome is always open and needs to stay that way for several
reasons. Do you know of a way to just change the normal view to design
view,
make the change to the label, save the form (without closing it) and
switch
back to normal view?


PMFJI, but how about making the visibility dependent on a field in a table,
and then just update that field. So that your form's Open event would check
the field value (probably using DLookup), and set the label's .Visible
property accordingly. Something like:

Private Sub Form_Open(Cancel As Integer)

Me.lblTestMode.Visible = _
Nz(Dlookup("TestModeLabelVisible", "tblConfiguration"), False)

End Sub

Of course, you'd have to set that field in the table at the point when you
decide the label should be visible henceforth. For example:

Forms!frmWelcome!lblTestMode.Visible = True

CurrentDb.Execute _
"UPDATE tblConfiguration SET TestModeLabelVisible = True", _
dbFailOnError
 

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