How to clear a filled combobox 
Author Message
 How to clear a filled combobox

Hi all,

In a Word project we use several comboboxes on a form. For some of
these it is allowed to leave them empty. This works fine: as long as
the user doesn't pick up a value from the list it is left empty.
The choosen data are stored in a document as customdocproperties.

A problem occurs when we reload the form, (programmatically) populate
the fields (including the comboboxes) with values from the
docproperties. This is to allow the users to change their mind and
pick-up/type in other values for the fields.
The problem: once the combobox is (programmatically) filled with the
data from the docproperties it is impossible for the user to empty/clear it
(when her/his mind changed to leave it blank in stead of using the
previous choosen value).

We were unable to find a property of the combobox that controls this
behaviour (empty-allowed....???).

Thanks in advance,

Hans Troost



Sun, 12 Sep 2004 04:25:23 GMT  
 How to clear a filled combobox
Hi Hans,

Quote:
> In a Word project we use several comboboxes on a form.

What kind of a form are we talking about, here? A VBA UserForm? A document
form with form fields? A document form with ActiveX controls?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

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



Wed, 15 Sep 2004 18:32:47 GMT  
 How to clear a filled combobox
Hi Cindy,

We are working with a VBA Userform. Hope this helps you to give me a
hint how to solve this problem.

Hans Troost

Quote:
> > In a Word project we use several comboboxes on a form.

> What kind of a form are we talking about, here? A VBA UserForm? A document
> form with form fields? A document form with ActiveX controls?



Sat, 18 Sep 2004 18:27:35 GMT  
 How to clear a filled combobox
Hi Hans,

Quote:
> We are working with a VBA Userform.

> A problem occurs when we reload the form, (programmatically) populate
> the fields (including the comboboxes) with values from the
> docproperties. This is to allow the users to change their mind and
> pick-up/type in other values for the fields.
> The problem: once the combobox is (programmatically) filled with the
> data from the docproperties it is impossible for the user to empty/clear it
> (when her/his mind changed to leave it blank in stead of using the
> previous choosen value).

1) Any time you have a combobox in a UserForm, it's populated
programmatically. there is no other way
2) If I set up a test UserForm, populate the combobox in the Initialize
event, and select a value - I can later (at any time) delete that value by
selecting it (Tab into the field) and presseing DEL

You mean to say that's not working?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

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



Sat, 18 Sep 2004 21:05:04 GMT  
 How to clear a filled combobox
Hi Cindy,

Your answer directed us to the solution. To be honest, I now realize
that I did not fully describe the required functionality of these
comboboxes and I apologize for that.
Now I will do so and add our solution. Hopefully it helps someone
else. Perhaps it is not the best one: in that case please comment on
it.

Th requirement really was:
1. Filling in a value in the combobox is optional. So it can be kept
empty or reset to empty
2. But.... if filled in, the value must match an entry in the list
(filled by data from a database).

Solution we found:

1. We played around with the Style property: it was set to 2:
fmStyleDropDownList and is now we set it to 0: fmStyleDropDownCombo
2. We now set the initial value of MatchRequired to False and use the
following programcode:

Private Sub cmb{*filter*}ubstance_Change()
    With cmb{*filter*}ubstance
        If .Text <> "" Then
            .MatchRequired = True
        Else
            .MatchRequired = False
        End If
    End With
End Sub

This works and we hope this is the best solution.

Thanks again for your support,

Hans Troost


Quote:
> Hi Hans,

> > ........

> 1) Any time you have a combobox in a UserForm, it's populated
> programmatically. there is no other way
> 2) If I set up a test UserForm, populate the combobox in the Initialize
> event, and select a value - I can later (at any time) delete that value by
> selecting it (Tab into the field) and presseing DEL

> You mean to say that's not working?

> Cindy Meister
>......



Mon, 20 Sep 2004 18:40:30 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Filling a Secondary Combobox based on information from a primary combobox

2. Clear fill when printing

3. How can i clear the MSHFLEXGRID without CLEAR - Como limpar a GRID sem usar CLEAR

4. Problem clearing Combobox values

5. Combobox Clearing problem

6. ComboBox Not Cleared

7. Clearing Combobox selection

8. How to Clear Text Field in ComboBox

9. Clearing a selected Combobox?

10. ComboBox.Clear event?

11. Clearing a dropdown list (ComboBox)

12. Add empty item for clearing of combobox .text/selection

 

 
Powered by phpBB® Forum Software