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

still confused about arrays

Status
Not open for further replies.

slwolf8

Technical User
Apr 23, 2001
82
US
I would like to make an array of the attorneys at my work and then add those names to several different combo boxes on different forms within a project. I figured most of it out but when I try to add the names to the combo box it is adding the index number instead of what the index represents. I have the following code in a module:

Public i as integer
Public Attorneys(79) as string

Sub AddAttorneys()
Attorneys(0) = "John Smith"
Attorneys(1) = "Bob Smith"
....etc.
End Sub

Then, in the initialize event of one of the userform I did the following:

For i = 0 to UBound(Attorneys)
cboAttorney.additem(i)
Next i

What am I missing? Thanks in advance.
 
you must call the subattorneys sub procedure before you load the form that fills the combo box.. hope that helps

Paul J.
 
I tried that and it is telling me "Wrong number of arguments or invalid property assignment"....the sub procedure I had was called addattorneys so I tried that too but it still didn't work...
 
just for testing purposes add the items to the array rght before you loop through the array. And see if you still get the same error. have the additem line like i showed above. Are you possibly going beyond the scope of the array?
 
Hi slwolf8,

Instead o flooping adding items just assign the whole array all at once ..

Code:
Me.cboAttorney.List = Attorneys

Enjoy,
Tony
 
Did that actually solve your problem? Cause that doesnt seem to be what your getting your error with.
 
Tony that worked, thanks. Now the question is did I do this the best way? Do I need to assign the items to the array in a sub routine or should I do that some other way? I want several different forms to be able to access this same array which is why I put it into a module.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top