Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    ScubaBart is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Jul 2024
    Posts
    117

    Next New Issue - Manipulating a standalone Label to change the text

    I have a couple forms that depending on the mode that I open them (whether to edit and existing record or add a new record), I want to have different Titles and Notes or instructions.



    I have tried so many different options including some in VBA and nothing is working.

    I have tried the box as both a standalone Label and an Unbound Text Box.

    Tried changing the Caption and the Value. Have used every imaginable variation of syntax.

    The typical error is that the referenced control is not found. Getting this in both Macro and VBA attempts.

    Surely it shouldn't be that hard to simply change the words in a Label or Text Box.


    What am I missing ???

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    No it is not.
    Label - Me.LabelName.Caption = "whatever"
    Textbox - Me.TextBoxName = "whatever"
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    To add to those comments, if the same form is being opened in different modes, then pass that mode value to the OpenArgs property of the opening form. Based on that, set the values of labels/controls.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    are u sure that form is already open? did u put ur text depending on condition in on load event?

  6. #6
    ScubaBart is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Jul 2024
    Posts
    117
    Quote Originally Posted by ano View Post
    are u sure that form is already open? did u put ur text depending on condition in on load event?

    Yes, here is the macro I am currently playing with and the form opens before the error pops up.

    Click image for larger version. 

Name:	Set_Property_MAcro.PNG 
Views:	23 
Size:	17.6 KB 
ID:	52160

    To all other replies, I have not had a chance yet to apply the ideas as they involve VBA and it will take me a little time to sit down and absorb the info. I am not well versed in VBA so it takes me a lot longer to create and troubleshoot that version of control.

    Will be working on it soon though and advise of progress as it is made.

  7. #7
    ScubaBart is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Jul 2024
    Posts
    117
    Quote Originally Posted by Welshgasman View Post
    No it is not.
    Label - Me.LabelName.Caption = "whatever"
    Textbox - Me.TextBoxName = "whatever"
    This is what I am trying

    Click image for larger version. 

Name:	OPen_Form_VBA_Code.PNG 
Views:	22 
Size:	18.1 KB 
ID:	52161

    This is what I get when I try to Compile

    Click image for larger version. 

Name:	Compile_Error.PNG 
Views:	24 
Size:	25.5 KB 
ID:	52162

    The form has the two Standalone Labels with just the names of the labels as filler text

    Click image for larger version. 

Name:	Form_Labels.PNG 
Views:	22 
Size:	8.6 KB 
ID:	52163

    So, what am I still doing wrong ?

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Me refers to the form you are running the code in.
    You would be better off setting it in the detsination form using OpenArgs.

    Otherwise you need something like
    Code:
    Forms!FormName!LabelName.Caption = "whatever"
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    ScubaBart is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Jul 2024
    Posts
    117
    Quote Originally Posted by Welshgasman View Post
    Me refers to the form you are running the code in.
    You would be better off setting it in the detsination form using OpenArgs.

    Otherwise you need something like
    Code:
    Forms!FormName!LabelName.Caption = "whatever"
    The example you provided works so I will use that.

    I am not familiar with OpenArgs. I may have to learn at some point but if I have something that works, I am going to use it.

    Is it safe to expect to be able to address all parameters in the same way as changing this caption ?

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    As long as they exist.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    You would be better off setting it in the detsination form using OpenArgs
    Thanks for seconding that
    According to how one interprets ms documentation it should be possible via macro but I'm not seeing how. I suspect TempVars is available though so that might be an alternative.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Yes, you can set Tempvars from within macros.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  13. #13
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    using docmd create new instance outside ur form, so ur caption need in other form on load

  14. #14
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    In the macros, the Value requires an =; Value ="Apiary Detail Edit"

    However that presents another problem discussed in google searches. The macro will not look at the form just loaded, it tries to apply the action to the form that executed the macro action.
    So the calling form needs to set a value for the called form to look at so that the called form can issue the macro action. Tempvars would work.
    Last edited by davegri; 08-29-2024 at 08:47 AM. Reason: sp

  15. #15
    ScubaBart is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Jul 2024
    Posts
    117
    Quote Originally Posted by davegri View Post
    In the macros, the Value requires an =; Value ="Apiary Detail Edit"

    However that presents another problem discussed in google searches. The macro will not look at the form just loaded, it tries to apply the action to the form that executed the macro action.
    So the calling form needs to set a value for the called form to look at so that the called form can issue the macro action. Tempvars would work.
    If that's the case with macros, that could explain several actions I'm having issues with.

    Have never worked with TempVars though so I am doing what someone above suggested and made a copy of the entire databse and turned all the macros into VBA for reference so I could start converting anything that was causing problems into code. So far, so good but I'm sure something will still cause me a problem.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Issue with label printing
    By SSSlippy in forum Programming
    Replies: 4
    Last Post: 10-04-2021, 08:35 AM
  2. Replies: 13
    Last Post: 09-16-2014, 01:55 PM
  3. Replies: 4
    Last Post: 02-21-2014, 01:29 AM
  4. Manipulating text string
    By genemd in forum Queries
    Replies: 4
    Last Post: 10-21-2011, 05:04 AM
  5. Replies: 1
    Last Post: 03-29-2009, 08:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums