Drop Down List >25 Lines

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to add a dropdown list to a form that has 52 lines (the 50 states
plus DC and PR). I just learned that the max is 25. It was suggested that i
use a combo box instead. I tried help, but cant figure out how to populate
the combo box with my list.

This has got to be simple, but then so am I.

Can anyone help guide me to the correct resource.

Thanks,
Rick
 
On Sat, 9 Jul 2005 13:45:07 -0700, Rick - MattsDad <Rick -
I am trying to add a dropdown list to a form that has 52 lines (the 50 states
plus DC and PR). I just learned that the max is 25. It was suggested that i
use a combo box instead. I tried help, but cant figure out how to populate
the combo box with my list.

This has got to be simple, but then so am I.

Can anyone help guide me to the correct resource.

Thanks,
Rick

Hi Rick,

Sorry to say, it does *not* have to be simple. This is Microsoft
you're dealing with, remember? ;-)

Whenever the document closes, the combo box loses all memory of its
contents, and it needs to be reloaded the next time the document is
opened. You need Document_New and Document_Open event procedures in
the ThisDocument module, both of which call a procedure to load the
box like this:

Private Sub Document_New()
PopulateStates
End Sub

Private Sub Document_Open()
PopulateStates
End Sub

Private Sub PopulateStates()
Dim MyArray As Variant
MyArray = Array("Alabama", "Alaska", "Arizona", _
"Arkansas", "California", "Colorado", _
"Connecticut", "Delaware", _
"District of Columbia", "Florida", _
"Georgia", "Hawaii", "Idaho", _
"Illinois", "Indiana", "Iowa", _
"Kansas", "Kentucky", "Louisiana", _
"Maine", "Maryland", "Massachusetts", _
"Michigan", "Minnesota", "Mississippi", _
"Missouri", "Montana", "Nebraska", _
"Nevada", "New Hampshire", "New Jersey", _
"New Mexico", "New York", "North Carolina", _
"North Dakota", "Ohio", "Oklahoma", _
"Oregon", "Pennsylvania", "Puerto Rico", _
"Rhode Island", "South Carolina", _
"South Dakota", "Tennessee", "Texas", _
"Utah", "Vermont", "Virginia", "Washington", _
"West Virginia", "Wisconsin", "Wyoming")
With cbxStates
.Clear
.List = MyArray
.ListIndex = 0
End With
End Sub

If you need to retain the user's choice when the document is closed
and reopened, you're also going to need FileSave and FileSaveAs macros
that save the current selection into a document variable, and then
you'll replace the .ListIndex = 0 (which displays Alabama) with some
code that reads the document variable and selects that value in the
list.

It sure would be nice if MS hadn't been so stingy with the dropdown
form field...
 
Jay Freedman said:
On Sat, 9 Jul 2005 13:45:07 -0700, Rick - MattsDad <Rick -


Hi Rick,

Sorry to say, it does *not* have to be simple. This is Microsoft
you're dealing with, remember? ;-)

Whenever the document closes, the combo box loses all memory of its
contents, and it needs to be reloaded the next time the document is
opened. You need Document_New and Document_Open event procedures in
the ThisDocument module, both of which call a procedure to load the
box like this:

Private Sub Document_New()
PopulateStates
End Sub

Private Sub Document_Open()
PopulateStates
End Sub

Private Sub PopulateStates()
Dim MyArray As Variant
MyArray = Array("Alabama", "Alaska", "Arizona", _
"Arkansas", "California", "Colorado", _
"Connecticut", "Delaware", _
"District of Columbia", "Florida", _
"Georgia", "Hawaii", "Idaho", _
"Illinois", "Indiana", "Iowa", _
"Kansas", "Kentucky", "Louisiana", _
"Maine", "Maryland", "Massachusetts", _
"Michigan", "Minnesota", "Mississippi", _
"Missouri", "Montana", "Nebraska", _
"Nevada", "New Hampshire", "New Jersey", _
"New Mexico", "New York", "North Carolina", _
"North Dakota", "Ohio", "Oklahoma", _
"Oregon", "Pennsylvania", "Puerto Rico", _
"Rhode Island", "South Carolina", _
"South Dakota", "Tennessee", "Texas", _
"Utah", "Vermont", "Virginia", "Washington", _
"West Virginia", "Wisconsin", "Wyoming")
With cbxStates
.Clear
.List = MyArray
.ListIndex = 0
End With
End Sub

If you need to retain the user's choice when the document is closed
and reopened, you're also going to need FileSave and FileSaveAs macros
that save the current selection into a document variable, and then
you'll replace the .ListIndex = 0 (which displays Alabama) with some
code that reads the document variable and selects that value in the
list.

It sure would be nice if MS hadn't been so stingy with the dropdown
form field...

WOW, talk about a thorough reply! Thanks. you've done all the work for me, i
just need to cut and past!

I really appreciate your help.

Rick - MattsDad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top