Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    Apr 2004
    Posts
    100

    Unanswered: Problem renaming a label on a subform

    Hello,

    could someone please help me with my stupid problem.
    I am using MS Access 2003 VBA for my forms. When using a mainform with 2 subforms how can I programmatically rename a label on the second subform out of the first subform?

    My MainForm is named Request.
    The first subform is named Resource.
    The second subform is named Resource_Line.
    The Label I want to rename is called [RESOURCE_LINE Subform_Label]

    Regards,
    Proximus
    Last edited by Proximus; 05-15-04 at 08:24.

  2. #2
    Join Date
    Feb 2004
    Location
    CT,USA
    Posts
    250
    Would you know where to put the code something like:
    subform2!Caption = "new label name"
    The reason I ask is that I'm unclear of what "Subform_Label" refers to in your program. Also, you may need to consider how to apply "subform2!Caption" because it probably won't work as written. Again because, I don't know where in your code you mean to apply it. Did you ever try changing the main forms caption programmatically, yet? Perhaps that should be your first step or test. Then you would only need to know when/where to change the subform name, which might be very tricky.

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    hmmm,

    renaming a label is quite an aggressive thing to do!

    are you sure you want/need to do that?

    you talk to a label thru it's "name" (not to be confused with it's caption). are you sure it is useful to rename a control?????

    is it even possible? (and if yes, why is it possible? what use can it serve?)
    currently using SS 2008R2

  4. #4
    Join Date
    Apr 2004
    Posts
    100
    Ups, sorry. Of course I meant the caption of a lable. Sorry again!

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ok, you have Resource_Line sitting in Resource sitting in Request

    and you want to talk to Resource_Line from Resource
    me!Resource_Line![RESOURCE_LINE Subform_Label].caption = "foo"

    or if you are not in a hurry
    forms!Request!Resource!Resource_Line![RESOURCE_LINE Subform_Label].caption = "foo"

    ...but do make sure the subform-control and sub-subform-control are called what you think they are called. the name is not necessarily the name of the .sourceobject form you designed.

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Apr 2004
    Posts
    100
    hmmm. exactly right. however it still doesn't work.

    I want to change the label every time the on current event of the resource form occurs.

    Sub Form_Current()
    Forms!Request![RESOURCE Subform]![Resource_Line Subform]![RESOURCE_LINE Subform_Label].Caption = "foo"
    end sub

    the forms caption are exactly as mentioned before. Maybe could you write me that code in another notation (like Me.request.)

    When I write the code in the Request form the subforms are known. However they aren't when writing the code in the Resource Subform.

    Sorry for my stupid question, but I really need help with that.
    Thanks in advance.
    Regards,
    Proximus
    Last edited by Proximus; 05-21-04 at 08:50.

  7. #7
    Join Date
    Apr 2004
    Posts
    100
    Is there nobody out there who could help me with that?

  8. #8
    Join Date
    Apr 2004
    Location
    Sydney Australia
    Posts
    369
    Quote Originally Posted by Proximus
    Is there nobody out there who could help me with that?
    The SetValue in a macro works for me.

    Item [Forms]![MasterForm]![SPPI]![Label41].[Caption]
    Expression "Whatever"

    Sorry, just noticed you want to trigger it from the fierst subform.
    Last edited by Mike375; 05-21-04 at 09:33.

  9. #9
    Join Date
    Apr 2004
    Location
    Sydney Australia
    Posts
    369
    That macro worked OnClick when placed on a label or field on the either of my two subforms and changed the label caption.

    But that would not be changing the name of the label?? Or would it?

    It definitely did not change the name because I just made a macro to mkae the label invisible and that worked up ran the macro that changed its name/caption
    Last edited by Mike375; 05-21-04 at 09:46.

  10. #10
    Join Date
    Apr 2004
    Posts
    100
    hmm.Thanks for your suggestion. I will try it.
    Sorry for my incorrect diction. Of course I meant the caption of a label, not its name.
    regards,
    proximus

  11. #11
    Join Date
    Apr 2004
    Posts
    100
    hmm. I don't like the solution with the macro though it works.

    It should be possible to access the Form "Resource_Line Subform" through code: So here again the situation:
    I have Resource_Line sitting in Resource sitting in Request
    and I want to talk to Resource_Line from Resource

    However the code that izyrider posted before doesn't work:
    Sub Form_Current()
    Forms!Request![RESOURCE Subform]![Resource_Line Subform]![RESOURCE_LINE Subform_Label].Caption = "foo"
    end sub

    Any ideas?

    And of course I want to change the caption of a label, not its name as misleadingly posted in the title.

  12. #12
    Join Date
    Apr 2004
    Location
    Sydney Australia
    Posts
    369
    This is the macro converted to code

    Forms!MasterForm!SPPI!Label41.Caption = "Whatever"

  13. #13
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    interestingly, my
    forms!mother!child!grandchild
    suggestion does not work -- i will look into this, because it should in principle work.

    meanwhile, a demo is attached using
    Me!grandchild

    izy
    currently using SS 2008R2

  14. #14
    Join Date
    Apr 2004
    Posts
    100
    hmm. your attached database works fine.
    However I am running crazy with my database. I have no clue why it doesn't work...

  15. #15
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    good (in the sense that maybe it can get fixed)!

    make sure your propeties window is open. then...

    open the child and click once on the grandchild control - it in the properties window/other/name: JimiHendrix

    now try whilst referring to it as me!jimi etc...

    izy
    currently using SS 2008R2

Posting Permissions

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