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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Procedure too long

Status
Not open for further replies.

craiogram

MIS
Feb 20, 2004
126
0
0
US
I'm using a form where in my Initialize sub I adding items to the various listboxes that are on the form but I guess I've gone beyond the allowable space. Is there some way to call a function or a sub-routine and pass it the listbox object so that I can fill the list in there? Or some other way to get all my listboxes filled with the all the values?

Thank you in advance...
 
Tough to answer without specifics. Have you looked at ParamArray in Access help?

"No matter what happens, somebody will find a way to take it too seriously."
 
It sounds like you're using code to enter the original values for your listbox. You can (and should) enter them in the design environment. Just go to the properties window of your listbox, find the list property, and enter them there. Use Ctrl-Enter to enter values, and use Enter when you're done. Finally, if you need to set values when you first open a form, don't use the Initialize event. Use the Load event instead. There are reasons for this that I won't get into here.

HTH

Bob
 
My apologies, I didn't post any solution because I thought it was just a knuckle head oversight on my behalf.

It turns out that I didn't have to pass the listbox at all.

I simply made the call to a sub from the initialize sub like this:

Code:
Private Sub UserForm_Initialize()
Call filllist1thru5
Call fillList6thru10
End Sub
then just filled the listboxes as I did in the initialzie sub like this:

Code:
With ListBox1
    .AddItems "Value1"
    .AddItems "Value2"
    etc
End With
With ListBox2
    .AddItems "Value1"
    .AddItems "Value2"
    etc
End With

I thought I had to pass the listbox but you can access it from both subs the same way.

Hope that helps.
 


craiogram,

You originally posted a similar question in Forum707

Is this being coded in an MS Office application VBA) or using VB?

Skip,
[sub]
[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue][/sub]
 
I'm sorry for any confustion. I placed this thread here by mistake but then couldn't delete it. It was handled in the VBA site. Please disregard this one.

Thank you.
 
You can always red flag an errant post, and explain that you have posted in the wrong forum. It'll get deleted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top