Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208

    Quote Originally Posted by davegri View Post
    This was as close as I could get. It will get a red fred.

    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Sub cmdAction_Click()
    With LabelB
        .Caption = "Fred"
        Call SetColor(Me.LabelB)
    End With
    End Sub
    
    
    Function SetColor(ctl As Control)
        ctl.BackColor = vbRed
    End Function
    Yeah, that works, but it still requires explicitly naming the outer object again. When the outer object is something with several levels deep dot notation, that is a nuisance. Thank you, but I've pretty well resigned myself to "it can't be done".

  2. #17
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by ssanfu View Post
    @pdanes,
    Wow! Really? Someone tries to help you and you respond like that?
    Your descriptions and explanations weren't clear to me either...... so I didn't respond.
    But it doesn't matter now - I've added you to my ignore list. Good luck with the other forums...
    I didn't notice any attempts to help - only snarky comments about pseudo-code and being specific, along with something that sounded like a knee-jerk reaction, rather than a response to what I actually wrote. And being on your ignore list suits me just fine - you have nothing useful to say either.

  3. #18
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,976
    @pdanes
    I believe I have helped you before now but your responses in this thread have alienated several experienced forum members including myself.
    Next time you post, you will get far fewer replies.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #19
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by isladogs View Post
    @pdanes
    I believe I have helped you before now but your responses in this thread have alienated several experienced forum members including myself.
    Next time you post, you will get far fewer replies.
    You have, and I am grateful for that. I have also helped others, here and in many other forums. But I try to help, not post useless criticisms. These two did not - they were insulting and condescending, and I have no use for that, on a forum or in person.

  5. #20
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,411
    Second try. It does allow an implicit call value. Fred is red.

    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Sub cmdAction_Click()
    
    
    With LabelB
        .Caption = "Fred"
        Call SetColor(.Name)
    End With
    End Sub
    
    
    Function SetColor(arg As String)
        Dim ctl As Control
        For Each ctl In Me.Controls
            If ctl.Name = arg Then
                ctl.BackColor = vbRed
                Exit For
            End If
        Next
    End Function

  6. #21
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by davegri View Post
    Second try. It does allow an implicit call value. Fred is red.

    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Sub cmdAction_Click()
    
    
    With LabelB
        .Caption = "Fred"
        Call SetColor(.Name)
    End With
    End Sub
    
    
    Function SetColor(arg As String)
        Dim ctl As Control
        For Each ctl In Me.Controls
            If ctl.Name = arg Then
                ctl.BackColor = vbRed
                Exit For
            End If
        Next
    End Function
    Hm, yes. Thank you, that's a good trick. It's still not a direct reference to the object itself, but using the Name property allows the syntax I was striving for.

    The sub needs to be coded to pick up the name, as you have done in your example, and the object must have a Name property, but most of the things I work with have that, and changing the sub to use the Name property is trivial. It's far better than repeating the entire initial reference.

    Many thanks, I'll put that in place wherever I can.

  7. #22
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,411
    Hm, yes. Thank you, that's a good trick. It's still not a direct reference to the object itself, but using the Name property allows the syntax I was striving for.

    The sub needs to be coded to pick up the name, as you have done in your example, and the object must have a Name property, but most of the things I work with have that, and changing the sub to use the Name property is trivial. It's far better than repeating the entire initial reference.

    Many thanks, I'll put that in place wherever I can.
    Glad I could help. Nice puzzle to work on. Good luck with the project.

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

Similar Threads

  1. New kid on the block
    By ldodge429 in forum Access
    Replies: 5
    Last Post: 07-17-2014, 08:45 PM
  2. Is Control inside Subform
    By CementCarver in forum Programming
    Replies: 3
    Last Post: 06-28-2013, 01:31 PM
  3. Replies: 1
    Last Post: 09-05-2012, 07:04 AM
  4. Replies: 5
    Last Post: 08-03-2012, 04:20 PM
  5. End While block problem
    By cbh35711 in forum Programming
    Replies: 4
    Last Post: 05-07-2012, 03:05 PM

Tags for this Thread

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