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

ListBox value when nothing selected

P: n/a
Hi,

I have a form in Access with a listbox containing some choices. There
is a "Select" button underneath that runs a macro opening a form that
acts on the selected value.
What I can't figure out is how to display an error, eg. "Please make a
selection" if nothing is selected and the "Select" button is clicked.

I'm trying an If Then Else statement worked into the button such as:
If listbox value=null, then error message. Else, run macro.
This hasnt worked, but it could just be that I don't know how to do it
properly.
The listbox is apparently unbound. (It's choices are derived from the
selection of another listbox)

Thanks in advance,
Josh

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
And then I found the answer somewhere else:

If listindex=-1 Then ...

Nov 13 '05 #2

P: n/a
Put the following code at the beginning of the code for your Select button:
If IsNull(Me!NameOfListbox) Then
MsgBox "Please Make A Selection",,"No Selection Made"
Me!NameOfListBox.SetFocus
Exit Sub
End If

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
<jp******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,

I have a form in Access with a listbox containing some choices. There
is a "Select" button underneath that runs a macro opening a form that
acts on the selected value.
What I can't figure out is how to display an error, eg. "Please make a
selection" if nothing is selected and the "Select" button is clicked.

I'm trying an If Then Else statement worked into the button such as:
If listbox value=null, then error message. Else, run macro.
This hasnt worked, but it could just be that I don't know how to do it
properly.
The listbox is apparently unbound. (It's choices are derived from the
selection of another listbox)

Thanks in advance,
Josh

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.