Word form dropdown and Userform listbox

D

Dale

Hello
I have a word form with two fields, one a dropdown the other a textfield.
The value selected from dropdown1 filters the values in a listbox1 on a
userform. The userform is triggered by a macro on the enter event of the
textfield. The textfield is populated with the value is selected from the
listbox once the user clicks on an "OK" command button. I have two small
problems I can't resolve:

1) is there a way to set the default value of the listbox, it seeems to open
with an item randomly preselected.

2) Every thing works as designed unless the user "changes" their mind after
both the dropdown and textfield have been populated. I can't seem to get
the listbox values to filter properly unless the dropdown is selected at
least twice, almost as if the dropdown isn't refreshing or requerying...how
do I get the dropdown and the listbox to always be in sync?

Thanks
 
C

Cindy M.

Hi Dale,
I have a word form with two fields, one a dropdown the other a textfield.
The value selected from dropdown1 filters the values in a listbox1 on a
userform. The userform is triggered by a macro on the enter event of the
textfield. The textfield is populated with the value is selected from the
listbox once the user clicks on an "OK" command button. I have two small
problems I can't resolve:

1) is there a way to set the default value of the listbox, it seeems to open
with an item randomly preselected.

You should be able to set this in the Properties window for the listbox. I
think the Value will let you set the Index of the list entry, or Text the text
of the entry you want selected.

If you're wanting to set this dynamically, set the value in the
UserForm_Initialization procedure.
2) Every thing works as designed unless the user "changes" their mind after
both the dropdown and textfield have been populated. I can't seem to get
the listbox values to filter properly unless the dropdown is selected at
least twice, almost as if the dropdown isn't refreshing or requerying...how
do I get the dropdown and the listbox to always be in sync?

Difficult to offer an opinion on this, based on the information you've
provided. I'd want to see any code connected with both the dropdown and the
textbox, as well as the UserForm_Initialize procedure and any other procedures
involved with preparing to present the UserForm.

I'd also want a more exact account of what "get the listbox values to filter
properly" means. How does the result differ from what you expect?

Connected to this problem... Are you unloading the userForm when the user
finishes, or just hiding it?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
D

Dale

Thanks Cindy
I've looked at the listbox properties and cannot find an entry that relates
to default, or text index or anything that gives me a clue as to how to set
the default selected text.

All the code, a case select statement with 2 case scenarios based on the
value of the dropdown1 are in the userform initialize event.
 
D

Doug Robbins - Word MVP

You use the ListIndex property of a listbox or combobox to set/retrieve the
selected item.

For the second issue, to get the On Entry event of the text FormField to
fire again, it is necessary to enter that formfield from another formfield.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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

Top