Connecting Tech Pros Worldwide Forums | Help | Site Map

Comb Boxes within a Sub-form

Mr Man
Guest
 
Posts: n/a
#1: Nov 13 '05
Is it possible to set the combo-box drop down list default to zero or
blank. Sometimes when you first view it, or not selected any data the
box has a selection in it, so you're not sure whether you have
selected an item or whether it's an old record. As my form has
several combo boxes it would look a lot better if all the combo boxes
were empty when you first open the form. Thank you in advance, all
help will be gratefully accepted

Tim Marshall
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Comb Boxes within a Sub-form


Mr Man wrote:
[color=blue]
> Is it possible to set the combo-box drop down list default to zero or
> blank. Sometimes when you first view it, or not selected any data the
> box has a selection in it, so you're not sure whether you have
> selected an item or whether it's an old record. As my form has
> several combo boxes it would look a lot better if all the combo boxes
> were empty when you first open the form. Thank you in advance, all
> help will be gratefully accepted[/color]

Unless you have a default value for the combo box, they should be null
when the form opens.

Now, if your combo boxes are bound, ie, there is a control source
(properties, data tab) for the box and if the field in the table
corresponding to that control source has a value then the combo box will
have a selection. OTOH, if you navigate through records, the selection
on the combo box will change to reflect the value just as if it were a
text box.

To set a combo box to no selection in code use me.cboComboBoxName = Null

To set a combo box to no selection (if your combo boxes are bound - see
above - are you sure you want to do this?) each time you bring up a new
record, use the On current event and do one of the following:

Private Sub Form_Current()

me.cboComboBoxName1 = Null
me.cboComboBoxName2 = Null

End Sub

If you have a large number of combo boxes and expect to add more:

Private Sub Form_Current()

Dim c As Access.Control

For Each c In Me.Controls

If c.ControlType = acComboBox Then c = Null

Next

End Sub


--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Joe.Mobley@nationalexpress.com
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Comb Boxes within a Sub-form



Tim Marshall wrote:[color=blue]
> Mr Man wrote:
>[color=green]
> > Is it possible to set the combo-box drop down list default to zero[/color][/color]
or[color=blue][color=green]
> > blank. Sometimes when you first view it, or not selected any data[/color][/color]
the[color=blue][color=green]
> > box has a selection in it, so you're not sure whether you have
> > selected an item or whether it's an old record. As my form has
> > several combo boxes it would look a lot better if all the combo[/color][/color]
boxes[color=blue][color=green]
> > were empty when you first open the form. Thank you in advance, all
> > help will be gratefully accepted[/color]
>
> Unless you have a default value for the combo box, they should be[/color]
null[color=blue]
> when the form opens.
>
> Now, if your combo boxes are bound, ie, there is a control source
> (properties, data tab) for the box and if the field in the table
> corresponding to that control source has a value then the combo box[/color]
will[color=blue]
> have a selection. OTOH, if you navigate through records, the[/color]
selection[color=blue]
> on the combo box will change to reflect the value just as if it were[/color]
a[color=blue]
> text box.
>
> To set a combo box to no selection in code use me.cboComboBoxName =[/color]
Null[color=blue]
>
> To set a combo box to no selection (if your combo boxes are bound -[/color]
see[color=blue]
> above - are you sure you want to do this?) each time you bring up a[/color]
new[color=blue]
> record, use the On current event and do one of the following:
>
> Private Sub Form_Current()
>
> me.cboComboBoxName1 = Null
> me.cboComboBoxName2 = Null
>
> End Sub
>
> If you have a large number of combo boxes and expect to add more:
>
> Private Sub Form_Current()
>
> Dim c As Access.Control
>
> For Each c In Me.Controls
>
> If c.ControlType = acComboBox Then c = Null
>
> Next
>
> End Sub
>
>
> --
> Tim http://www.ucs.mun.ca/~tmarshal/
> ^o<
> /#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
> /^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me[/color]

Closed Thread