By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,397 Members | 1,417 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,397 IT Pros & Developers. It's quick & easy.

Comb Boxes within a Sub-form

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Mr Man wrote:
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


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
Nov 13 '05 #2

P: n/a

Tim Marshall wrote:
Mr Man wrote:
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
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


Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.