passing frame name as param

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

passing frame name as param

Post by sal21 »

How to pass the name of frame as param... in my case Frame4

Code: Select all

Private Sub CONTROLLO_CAMPI_SCHEDE()

    ER = 0
    lCtr = 0

    For Each CCONT In Me.Controls
        If TypeName(CCONT) = "ComboBox" Or TypeName(CCONT) = "TextBox" Then
            If CCONT.Container.Name = "[b]Frame4[/b]" Then
                If Trim(CCONT.Tag) >= "" And CCONT = "" And CCONT.Tag <> 99 Then
                    TG = CCONT.Tag
                    'Debug.Print TG & "-" & CCONT.Name
                    Call SELECT_CASE_SCHEDE(TG)
                    ER = ER + 1
                End If
            End If
        End If
    Next

End Sub

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: passing frame name as param

Post by HansV »

Code: Select all

Private Sub CONTROLLO_CAMPI_SCHEDE(FrameName As String)

    ER = 0
    lCtr = 0

    For Each CCONT In Me.Controls
        If TypeName(CCONT) = "ComboBox" Or TypeName(CCONT) = "TextBox" Then
            If CCONT.Container.Name = FrameName Then
                If Trim(CCONT.Tag) >= "" And CCONT = "" And CCONT.Tag <> 99 Then
                    TG = CCONT.Tag
                    'Debug.Print TG & "-" & CCONT.Name
                    Call SELECT_CASE_SCHEDE(TG)
                    ER = ER + 1
                End If
            End If
        End If
    Next

End Sub
Use like this in the same module:

Code: Select all

    Call CONTROLLO_CAMPI_SCHEDE("Frame4")
Best wishes,
Hans

User avatar
SpeakEasy
4StarLounger
Posts: 536
Joined: 27 Jun 2021, 10:46

Re: passing frame name as param

Post by SpeakEasy »

Hans has provided the direct answer - but were you really simply asking is how to pass a string as a parameter - I suspect there may be more to your question than initially appears.

Perhaps you really mean how you could pass control by name?

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

Re: passing frame name as param

Post by sal21 »

HansV wrote:
07 Sep 2022, 07:14

Code: Select all

Private Sub CONTROLLO_CAMPI_SCHEDE(FrameName As String)

    ER = 0
    lCtr = 0

    For Each CCONT In Me.Controls
        If TypeName(CCONT) = "ComboBox" Or TypeName(CCONT) = "TextBox" Then
            If CCONT.Container.Name = FrameName Then
                If Trim(CCONT.Tag) >= "" And CCONT = "" And CCONT.Tag <> 99 Then
                    TG = CCONT.Tag
                    'Debug.Print TG & "-" & CCONT.Name
                    Call SELECT_CASE_SCHEDE(TG)
                    ER = ER + 1
                End If
            End If
        End If
    Next

End Sub
Use like this in the same module:

Code: Select all

    Call CONTROLLO_CAMPI_SCHEDE("Frame4")
TKS.
So simple...
i'm stupid.