Change form property at runtime

  • Thread starter Thread starter Rick Brandt
  • Start date Start date
R

Rick Brandt

johnb said:
Hi Guys,

I can change a controls visible property at runtime using a cmd button,
but I can't seem to save the new setting when I close the Form and reopen
it. The following code works fine apart from persisting the changes
For Each ctl In frm.Controls

If ctl.ControlType = acLabel And ctl.Name = Me.GroundInFocus.Value
Then
str = "I-" & Mid(ctl.Name, 1, 11)

If Me(str).Visible = True Then
Me(str).Visible = False
Me(str).Properties("Visible").Value = False
Else
Me(str).Visible = True
Me(str).Properties("Visible").Value = True
End If

End If

Next ctl
Set ctl = Nothing

Any suggestion?

Changes made to a form or report in normal view via code are not supposed to
be persisted. For that you open the form in design view.
 
Hi Guys,

I can change a controls visible property at runtime using a cmd button, but
I can't seem to save the new setting when I close the Form and reopen it. The
following code works fine apart from persisting the changes
For Each ctl In frm.Controls

If ctl.ControlType = acLabel And ctl.Name = Me.GroundInFocus.Value Then
str = "I-" & Mid(ctl.Name, 1, 11)

If Me(str).Visible = True Then
Me(str).Visible = False
Me(str).Properties("Visible").Value = False
Else
Me(str).Visible = True
Me(str).Properties("Visible").Value = True
End If

End If

Next ctl
Set ctl = Nothing

Any suggestion?

TIA
johnb
 
Hi Rick
Thanks for the comments. I need to hide a label during one session of the
open Form and carry that hidden label to next Form open session. How do I
persist a hidden label over a Form closing and re-opening?

Regards
johnb
 
johnb said:
Hi Rick
Thanks for the comments. I need to hide a label during one session of the
open Form and carry that hidden label to next Form open session. How do I
persist a hidden label over a Form closing and re-opening?


Save, in a configuration table, the desired initial visibility of the
control. In the form's Open event, look up the value of the field in the
table and use it to set the control's Visible property.
 
Hi Dirk,
Thank you for the info. I've done just that! And it works fine. I was hoping
that I could get Access to do the work.

Regards
johnb
 
johnb said:
Hi Dirk,
Thank you for the info. I've done just that! And it works fine. I was
hoping
that I could get Access to do the work.

The only alternative I can think of is to create a custom property of the
form and use that. However, that's not really any better than just doing
what Access is designed to do: store information in tables.
 
Back
Top