Change form property at runtime

Discussion in 'Access VBA Modules' started by Rick Brandt, May 31, 2010.

  1. Rick Brandt

    Rick Brandt Guest

    johnb wrote:

    > 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.
     
    Rick Brandt, May 31, 2010
    #1
    1. Advertisements

  2. Rick Brandt

    johnb Guest

    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
     
    johnb, May 31, 2010
    #2
    1. Advertisements

  3. Rick Brandt

    johnb Guest

    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

    "Rick Brandt" wrote:

    > johnb wrote:
    >
    > > 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.
    > .
    >
     
    johnb, May 31, 2010
    #3
  4. Rick Brandt

    Dirk Goldgar Guest

    "johnb" <> wrote in message
    news:...
    > 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.

    --
    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    (please reply to the newsgroup)
     
    Dirk Goldgar, May 31, 2010
    #4
  5. Rick Brandt

    johnb Guest

    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

    "Dirk Goldgar" wrote:

    > "johnb" <> wrote in message
    > news:...
    > > 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.
    >
    > --
    > Dirk Goldgar, MS Access MVP
    > Access tips: www.datagnostics.com/tips.html
    >
    > (please reply to the newsgroup)
    >
     
    johnb, Jun 1, 2010
    #5
  6. Rick Brandt

    Dirk Goldgar Guest

    "johnb" <> wrote in message
    news:...
    > 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.

    --
    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    (please reply to the newsgroup)
     
    Dirk Goldgar, Jun 1, 2010
    #6
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Dennis W. Bulgrien

    Changing Field Property AllowZeroLength Doesn't Change Design

    Dennis W. Bulgrien, Sep 11, 2003, in forum: Access VBA Modules
    Replies:
    2
    Views:
    145
    Tim Ferguson
    Sep 11, 2003
  2. DOYLE60

    How to change tab page with OnCurrent Property

    DOYLE60, Oct 22, 2003, in forum: Access VBA Modules
    Replies:
    2
    Views:
    133
    John Spencer (MVP)
    Oct 24, 2003
  3. Tom

    Change Run Permissions property

    Tom, Jan 1, 2004, in forum: Access VBA Modules
    Replies:
    6
    Views:
    130
    Tim Ferguson
    Jan 2, 2004
  4. Niels
    Replies:
    2
    Views:
    693
    Niels
    May 11, 2004
  5. Air DeCHOso

    Change ValidationRule Property with VBA Code?

    Air DeCHOso, Jul 15, 2004, in forum: Access VBA Modules
    Replies:
    1
    Views:
    138
    Tim Ferguson
    Jul 16, 2004
  6. Tran Hong Quang

    Change MultiSelect property of ListBox during runtime

    Tran Hong Quang, Jan 27, 2006, in forum: Access VBA Modules
    Replies:
    3
    Views:
    179
    Tran Hong Quang
    Jan 27, 2006
  7. DaBartman

    Startup problem with runtime and no-runtime apps

    DaBartman, Jul 11, 2006, in forum: Access VBA Modules
    Replies:
    1
    Views:
    198
    Brian
    Jul 11, 2006
  8. dch3
    Replies:
    4
    Views:
    252
    Tony Toews [MVP]
    Aug 17, 2008
Loading...