Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which listbox is calling the function 2

Status
Not open for further replies.

JeremyReurich

Technical User
Apr 3, 2005
3
I have a number of listbox's named Listbox1, Listbox2 etc.
In their "row source type" a function is called that populated the listbox. I want to know the name of which listbox is calling this function (I will use this to change some of the entries in the list)
Does anyone know how to find out this name?
 
How are ya JeremyReurich . . .

Add and additional arguement to the function for this:
Code:
[blue]Function [i]FunctionName[/i](lbxName as String, YourArguement, . . .)[/blue]
For each listbox the call would look like:
Code:
[blue][i]FunctionName[/i]("Listbox1", YourArguement, . . .)[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks Aceman for your prompt reply.
I am still hitting my head against the wall though...
Do you have any more advice?

When I try what you suggested in adding the name argument to the call in the "Row Source Type" I get an error saying that "it is not a valid setting" for RowSourceType property.

This is what I am doing:
In the Listbox RowSourceType I have FillListTeamX
The code that is called is:

Code:
'This Function fills the ListBoxes (ListTeam1 etc) that call it in the "row source type".
'It fills it with the Kids names & their team based on the function

Function FillListTeamX(fld As Control, id As Variant, _
    row As Variant, col As Variant, code As Variant) _
     As Variant
     
On Error GoTo Err_FillListTeamX

Dim intOffset As Integer
Dim GroupChosen As Integer
Static Kids As Variant, Entries As Integer, ListNum As Integer
    
   
   
    Select Case code
        Case acLBInitialize    [COLOR=red]        ' Initialize.[/color]
            Kids = WhereAreThey() [COLOR=red]'fills array-WORKS![/color]    
            Entries = Kids(0, 0)
   [COLOR=green] This is where I want to add a statement/s that will get the name of the listbox that is calling this function to be used in the IF/THEN statement in the "Case acLBGetValue" section. [/color]          
            FillListTeamX = True

        Case acLBOpen                   [COLOR=red] ' Open.[/color]
            FillListTeamX = Timer       [COLOR=red] ' Unique ID. [/color]
        Case acLBGetRowCount          [COLOR=red]  ' Get rows.
            FillListTeamX = Entries
        Case acLBGetColumnCount   [COLOR=red] ' Get columns.[/color]
            FillListTeamX = 1
        Case acLBGetColumnWidth    [COLOR=red]' Get column width.[/color]
            FillListTeamX = -1          [COLOR=red]  ' Use default width.[/color]
        Case acLBGetValue             [COLOR=red]   ' Get the data.[/color]
                          
                    If ListNum = Kids((row + 1), 1) Then
                        FillListTeamX = Kids((row + 1), 1)
                    End If
            
    End Select
    
Exit Function
Err_FillListTeamX:
MsgBox Err.Description
End Function
 
Hi Jeremy,

The first argument should be the calling control.

So adding

debug.print fld.name

after "On Error GoTo Err_FillListTeamX" should identify the listbox. I thought learning how to use list callback functions was excruciating, but eventually worth the pain. Particularly in pre A2003 versions where listboxes don;t have recordsources. Good luck.

Cheers,
Bill
 
Sorry JeremyReurich . . .

I've never had to use a callback function.

Calvin.gif
See Ya! . . . . . .
 
Thanks Aceman & FormerTexan - Your responses helped answer my question (looks more obvious now in hindsight!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top