Change form property at runtime

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

  1. Rick Brandt

    Rick Brandt Guest

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

    Dirk Goldgar Guest


    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, 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
     
    johnb, Jun 1, 2010
    #5
  6. Rick Brandt

    Dirk Goldgar Guest

    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, Jun 1, 2010
    #6
    1. Advertisements

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