473,385 Members | 1,582 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,385 software developers and data experts.

No Value selected check on ListBox

553 512MB
How to check if No Value was selected from List-Box without using any built-in Events ?
Jul 25 '07 #1
6 27134
MikeTheBike
639 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
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
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
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. Public Sub cmd_btn_Click()
  2.   If IsNull(ComboBox0.Value)  Then 
  3.    '  Do something
  4.   End If
  5. End Sub
Linq ;0)>
Jul 25 '07 #5
MikeTheBike
639 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. Public Sub cmd_btn_Click()
  2. If ComboBox0.Value = ""  Then   <-- this or anyother method doesn't work, why?
  3. '  Do something
  4. End If
The last time I look a button click was classed as an event !

Expand|Select|Wrap|Line Numbers
  1. If Combo0.ListIndex = -1 Then
  2.     MsgBox "No Selection"
  3. Else
  4.     MsgBox "Item " & Combo0.ListIndex & " Selected"
  5. End If
Should do it?

ListIndex is Zero based.

MTB
Jul 25 '07 #6
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. If Combo0.ListIndex = -1 Then
  2.     MsgBox "No Selection"
  3. Else
  4.     MsgBox "Item " & Combo0.ListIndex & " Selected"
  5. End If
Should do it?

ListIndex is Zero based.

MTB
Jul 25 '07 #7

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

Similar topics

5
by: Coz | last post by:
Hi all, I'm looking for help again!!! I have been writing a page to update a database but now have another 'silly' problem with listbox's...Grrr... I'm trying to populate the list box with...
3
by: Fendi Baba | last post by:
I am trying to write a simple Javascript code to pass value from a listbox to another field the following is my code f=document.forms; window.alert(f.FieldList.options.length)...
9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
5
by: RBohannon | last post by:
I have a multi-selectable listbox named lstTitles. In the OnClick event I had the following: If Not IsNull(Me.lstTitles) Then ' do something with list selection Else ' do something else End...
1
by: Raymond | last post by:
I have a WebForm with a ListBox in it. This SelectionMode is set to Multiple. When a button is clicked, I check what items are selected using: foreach (ListItem itm in lb.Items) {...
4
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item,...
10
by: ken | last post by:
Hi, Say I have a list box. I also created a control on a form bound to that list box. When I click different rows in the listbox the control changes the ID of the row depending on what I click. ...
1
by: acord | last post by:
Hi, I am having problem to get a value of the selected item from a dropdown listbox. Here is the JS function; function getSelectedItem(objSelect) { alert("in getSelectedItem"); alert...
2
by: php_Boi | last post by:
i have designed an application that is a dynamic submission form. i have text fields and listboxes. now i am able to retain the values of the listboxes when i populate the listbox "manually"(single...
3
by: WolfgangD | last post by:
Hi, I have got a prblem: I created a checkbox, this checkbox will get the informations from a text file : FileStream mem_name = new FileStream(pfad, FileMode.Open, FileAccess.Read);...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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...

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.