473,513 Members | 2,399 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comb Boxes within a Sub-form

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
2 1555
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7713
by: Steve | last post by:
Hi all i am writing a small program and what i need to do is have some code that will do the following: When i press a key within a text box it will type that letter/number in and then move to...
9
4057
by: Dustin | last post by:
Here's what I am trying to do: (Names represent CSS classes.) I want to create a photo gallery. I want the entire gallery to be surrounded by a box named PhotoGallery. I want a fluid placement...
7
10125
by: Mark | last post by:
Hi All, I have a report which is based on a query which is used to produce QC check sheets. I have quite a few text boxes which are used to display questions depending on the value of one...
3
2577
by: Shannan Casteel via AccessMonster.com | last post by:
I have three main tables. The first is the table that my main form will be based on. This is where the user will enter all the data. The table is called TechnicalProblemsTable. It looks like...
8
10071
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
15
1646
by: deanndra | last post by:
I thought I had it figured out yesterday. WRONG! I have 2 combo boxes, CBUnit and CBSub. When value is clicked within CBUnit, it should bring up corresponding sub-values in CBSub. These combo boxes...
2
1757
by: ARC | last post by:
I'm testing a user's db that contains a very large number of records. I have an invoice screen, with an invoice select dropdown box that shows all invoices, and the customer's name, etc. With...
1
1173
by: grahamlabdon | last post by:
Hi Everyone I have a group box that contains 2 labels and 2 combo boxes I have a DataView object that I want to set as the data source for the combo boxes In addition I want to add a data...
6
9575
patjones
by: patjones | last post by:
Sometimes you might have two list boxes side by side, and want to double-click on an item in one box to move it to the other. For instance, maybe the first list box contains a list of customers,...
1
1786
by: adarshyam | last post by:
can anybody tel me how to clear values from dynamically created text boxes?? using a clear button.. this is the code used to create dynamic text boxes.. if i press clear button then it must clear all...
0
7265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7545
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7111
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7539
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5095
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.