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

making sure that a selection has been made in a combobox

P: n/a

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
Share this Question
Share on Google+
3 Replies


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

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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.