Passing a listbox to a subroutine

Magster

Registered User.
Local time
Yesterday, 22:45
Joined
Jul 30, 2008
Messages
115
Hello all,

I have a form with several list boxes. After the users makes their selections, I want to pass each listbox to a subroutine to extract the user's selections. All of this work is being done in one form.

This is the subroutine: Sub AllListBoxes(lstTemp As ListBox)
This is the calling routine: AllListBoxes Me.lstAgencies

When I check the value of the listbox, it is null. Can I pass a listbox like this? Or does this have to be passed as an object not specifically a listbox object?
 
It depends on how you are checking the value of the List Box.
MsgBox lstTemp
will produce Null if no selection is made or the List Box is set to Multi Select.

However, the same would be true if
MsgBox Me.lstAgencies
was used before calling the Sub.

The call of the Sub is fine, you probably have the failing List Box set to Multi Select.

Chris.
 

Users who are viewing this thread

Back
Top Bottom