Access VBA ListBox check if selected

No Value selected check on ListBox

questionit
553 512MB
How to check if No Value was selected from List-Box without using any built-in Events ?
Jul 25 '07 #1
Follow Post Reply
Access VBA ListBox check if selected
Access VBA ListBox check if selected
Access VBA ListBox check if selected
6 26539
MikeTheBike
637 Expert 512MB
Hi
How to check if No Value was selected from List-Box without using any built-in Events ?
If you do not use an event, how does Access know you want to know if anything is selected ?

MTB
Jul 25 '07 #2
reply
questionit
553 512MB
I thought it would be possible to do like that.

for example, i click on a button and i write the following code :

[code]
Public Sub cmd_btn_Click()
If ComboBox0.Value = "" Then <-- this or anyother method doesn't work, why?
' Do something
End If

Hi

If you do not use an event, how does Access know you want to know if anything is selected ?

MTB
Jul 25 '07 #3
reply
Access VBA ListBox check if selected
FishVal
2,653 Expert 2GB
How to check if No Value was selected from List-Box without using any built-in Events ?
Depends on MultiSelect property of ListBox.

For ListBox with MultiSelect set to None
ListBox.Value = Null
when nothing is selected

For ListBox with MultiSelect set to Simple/Extended
ListBox.ItemsSelected.Count = 0
when nothing is selected
Jul 25 '07 #4
reply
Access VBA ListBox check if selected
missinglinq
3,532 Expert 2GB
He says "listbox" in his title but from his code he's using a combobox. This should do it
Expand|Select|Wrap|Line Numbers
  1. PublicSubcmd_btn_Click()
  2. IfIsNull(ComboBox0.Value)Then
  3. 'Dosomething
  4. EndIf
  5. EndSub
Linq ;0)>
Jul 25 '07 #5
reply
MikeTheBike
637 Expert 512MB
I thought it would be possible to do like that.

for example, i click on a button and i write the following code :

Expand|Select|Wrap|Line Numbers
  1. PublicSubcmd_btn_Click()
  2. IfComboBox0.Value=""Then<--thisoranyothermethoddoesn'twork,why?
  3. 'Dosomething
  4. EndIf
The last time I look a button click was classed as an event !

Expand|Select|Wrap|Line Numbers
  1. IfCombo0.ListIndex=-1Then
  2. MsgBox"NoSelection"
  3. Else
  4. MsgBox"Item"&Combo0.ListIndex&"Selected"
  5. EndIf
Should do it?

ListIndex is Zero based.

MTB
Jul 25 '07 #6
reply
questionit
553 512MB
Yes that works MTB

Thanks

The last time I look a button click was classed as an event !

Expand|Select|Wrap|Line Numbers
  1. IfCombo0.ListIndex=-1Then
  2. MsgBox"NoSelection"
  3. Else
  4. MsgBox"Item"&Combo0.ListIndex&"Selected"
  5. EndIf
Should do it?

ListIndex is Zero based.

MTB
Jul 25 '07 #7
reply
Message
Cancel Changes

Post your reply

Sign in to post your reply or Sign up for a free account.

Post Reply

Similar topics

ASP / Active Server Pages
Listbox problem - taking initial value from database
5 posts views Thread by Coz | last post: by
Javascript
How I extract value from selected arrays
3 posts views Thread by Fendi Baba | last post: by
Microsoft Access / VBA
Help Using Text Box to fill a Listbox
9 posts views Thread by Megan | last post: by
Microsoft Access / VBA
Listbox Value is Null when listbox is clicked
5 posts views Thread by RBohannon | last post: by
ASP.NET
Only the first ListItem is selected in a ListBox
1 post views Thread by Raymond | last post: by
ASP.NET
returning the selected value of a listbox control inside a user control - please urgent!
4 posts views Thread by Moe Sizlak | last post: by
Microsoft Access / VBA
Listbox value does not change
10 posts views Thread by ken | last post: by
Javascript
Return a value of the selected item from a dropdown listbox
1 post views Thread by acord | last post: by
PHP
retaining value in listbox array
2 posts views Thread by php_Boi | last post: by
C# / C Sharp
Checkbox Default Value
3 posts views Thread by WolfgangD | last post: by
eCommerce
Access VBA ListBox check if selected
The Best Way to Hire eCommerce Web Developers in 2022
reply views Thread by eddparker01 | last post: by
Mobile Development
Access VBA ListBox check if selected
How to Hire a Programmer in 6 Easy Steps for a Startup
reply views Thread by eddparker01 | last post: by
General
lancet: a comprehensive, efficient, and reusable util function library of go
reply views Thread by lanliddd | last post: by
Microsoft Access / VBA
Access VBA ListBox check if selected
TIP: Drag & Drop with Database Objects
1 post views Thread by isladogs | last post: by
Software Development
Remote Development and Debugging Tools
reply views Thread by Trystan | last post: by
General
java
1 post views Thread by Sarah2002 | last post: by
General
Calculated field in subform that takes values from main form
reply views Thread by OgaSkuhc | last post: by
Python
Issue of tkinter
reply views Thread by alirafay | last post: by
Microsoft Access / VBA
When inventory is not yet sold
4 posts views Thread by cmo187265 | last post: by