473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

making sure that a selection has been made in a combobox


Hi again.

I am trying to figure out how to make sure that a value has been
selected from a combobox on a form. I have tried using
isnull(comboboxname.text) and
isempty(comboboxname.text)and isnull(comboboxname.value) in the onexit
event but I cannot get it to work.

basically the combo contains a value list of possible salutations(e.g.
Mr., mrs., etc.) and I want to be sure that the user chooses one of the
salutations before they can do anything else.

thank you

Colin
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
3 2347
IsNull(ComboBox.Value) or just IsNull(ComboBox) (because Value is the
default property of an Access combo box) should work in most circumstances.
IsNull(ComboBox.Text) won't work, because the Text property returns a
String, and a String cannot be Null. IsEmpty(ComboBox.Text) or
IsEmpty(ComboBox.Value) won't work, as I understand it, because IsEmpty()
returns true only when the argument is an uninitialised Variant *variable*,
to the best of my knowledge, there is no way for a control property to
return the Empty value.

One situation in which IsNull(ComboBox) or IsNull(ComboBox.Value) may not
meet your needs is where the combo box contains a zero-length string. The
following expression will return True if the control contains either Null or
a zero-length string ...

Len(ControlName & vbNullString) = 0

.... and the following expression will also return True if the control
contains nothing but spaces ...

Len(Trim$(ControlName & vbNullString)) = 0

--
Brendan Reynolds
"ColinWard" <je*********@hotmail.com> wrote in message
news:40*********************@news.frii.net...

Hi again.

I am trying to figure out how to make sure that a value has been
selected from a combobox on a form. I have tried using
isnull(comboboxname.text) and
isempty(comboboxname.text)and isnull(comboboxname.value) in the onexit
event but I cannot get it to work.

basically the combo contains a value list of possible salutations(e.g.
Mr., mrs., etc.) and I want to be sure that the user chooses one of the
salutations before they can do anything else.

thank you

Colin
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2
DFS
Set the Default value to something in the comboBox, then set the validation
rule to Not Null
"ColinWard" <je*********@hotmail.com> wrote in message
news:40*********************@news.frii.net...

Hi again.

I am trying to figure out how to make sure that a value has been
selected from a combobox on a form. I have tried using
isnull(comboboxname.text) and
isempty(comboboxname.text)and isnull(comboboxname.value) in the onexit
event but I cannot get it to work.

basically the combo contains a value list of possible salutations(e.g.
Mr., mrs., etc.) and I want to be sure that the user chooses one of the
salutations before they can do anything else.

thank you

Colin
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #3
thank you both for your replies. I did what DFS suggested and it worked
perfectly.

Colin
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Programatix | last post by:
Hi, I'm having problem with ComboBox. I'm trying to force the ComboBox select nothing by doing this, myCombo.SelectedText = "" myCombo.SelectedIndex = -1 but in vain, as the ComboBox will...
1
by: Steve | last post by:
I have a continuous form with several unbound comboboxes in the form header. The comboboxes are used to provide criteria for the SQL of the form. The code behind the form looks like: Public Sub...
5
by: njb35 | last post by:
Hi all I'm beginning my foray from VBA into VB 2005 Express, and enjoying some of the efficiencies it provides! I'm stuck with some dataset handling however that I _think_ can be automated but...
0
by: jimmarq | last post by:
I am creating a windows form application in VB.NET 2.0. I have a datagridview, and one of the columns ("SelectorColumn") is a Combobox. The combobox values come from a dataset, and the column is...
2
by: jujubean | last post by:
I have a form with five comboboxes. In the first, the user can select one of four items. The other four comboxes are hidden. Based on the selection made in combobox one, I would like one of the...
4
by: Mtek | last post by:
Hi, We have a combo box on our page, which gets populated via a MySQL Query in PHP. What we want to do is to print the values on the page in a table that correspond the to selection from the...
1
by: Rosie | last post by:
I have a main form with header info w/ 'tHeader' as the control source. I have a subform with 'tDetail' as a control source. They're strung together by a field named MA_ID. This works...
1
by: StuartD | last post by:
I have a sub form that is populated based on the selection of a year from a combo box on the main form. I'm trying to add a second main form combo box for item category to further filter the sub...
21
by: kurai hikari | last post by:
i have a combobox from table( specialization) and i have a reports from table (managers) the combobox name is( combo1) the selections in the combo box are managersjob governorsjob...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.