Changing label captions with VBA

Ask a Question related to Microsoft Access, Design and Development.

  1. #1

    Default Re: Changing label captions with VBA

    If you make the changes in design view, and save the form, Access saves the
    changes.
    If you change them programatically and then close the form without using
    design view, the changes are not saved.
    If you change them programatically, switch to design view, make other
    changes, switch back to form view, and then save them, the design changes
    are saved.

    BTW, Neal, I did a form like that several years ago. I used text boxes
    instead of labels, and programatically set the date for each text box in
    Form_Open. The Format property of the text boxes was just d, so they showed
    just the day of the month. Under each text box was a subform: yes 35
    instances of the same subform. The LinkMasterFields/LinkChildFields
    properties used the date in the text box so that the right information
    automatically appeared in the subforms for each date.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - [url]http://allenbrowne.com/tips.html[/url]
    Reply to the newsgroup. (Email address has spurious "_SpamTrap")

    "Neal Tipton" <tipton@gvtc.com> wrote in message
    news:0TfVa.829$V_4.34708@eagle.america.net...
    > I have an unbound form that is a one year calendar. The days for each
    month
    > are made of 42 labels (6 rows of 7 plain boxes) with sequential names and
    on
    > the form's open event, each label is made visible or invisible, and it's
    > caption is changed to the day of the month. In addition, the 12 labels
    for
    > the months have their captions changed to the appropriate month of the
    year.
    > Here's the problem: I have noticed when I first started working with this
    > form that whenever I closed the form and opened it in design mode the
    > changes made to each label were gone and the original captions were
    > reinstated. This was always the case until I started tweaking the
    form_open
    > event to also read in special abbreviated notations for marked days from a
    > table. Now it saves the altered version of the calendar and the caption
    > changes can still be seen if you open the form in design mode. This is
    not
    > so much of a problem, really except that I don't know what the rule is.
    > WHEN does Access make changes to labels made via VBA permanent and when
    does
    > it not?
    >
    >

    Allen Browne Guest

  2. Similar Questions and Discussions

    1. Changing Label Text in CFINPUT
      Does anyone know how to change the label text in a CFINPUT statement. I have the style information set to a larger font and I want the label text to...
    2. Changing text on asp-label
      Is it possible to change the text in a label from english to german like cultureinfo in Visual studio? regards reidarT
    3. Changing text of a label inside a control...
      Hello there, I need to change the text of a label inside a datagrid. The label is part of an <EditItemTemplate > Can anyone post code of how...
    4. Changing the font and size for a button label
      How do I change the font and size for a button label, textboxes etc. It seems easy to do in MS FrontPage but I'm have problems doing that in...
    5. Forms - multi-column sort, export label captions
      Good day, I have 2 questions and hopefully someone can help me or give me some ideas. Firstly, I would like to be able to export data from a form...
  3. #2

    Default Re: Changing label captions with VBA

    To programatically (VBA) modify a form or report label in Access (I'm using 2010), you need to use .Caption

    Me. (means the form you are in. You can also explicitely refer to the form using the following Forms!frm_Name!labelname)

    Me.Label11.Caption = "new label text"

    It is that easy.
    vanauden is offline Junior Member
    Join Date
    Feb 2011
    Location
    Canada
    Posts
    1

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139