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

detect 'all' from combobox

Hi All,

I've added an 'All' item to my combobox(below) and it does display as
the first item

If Me.cboLOB.Column(0) = "auto" Then
strSQL = "SELECT DISTINCT tblAUTO_MASTER.Section" & _
" FROM tblAUTO_MASTER" & _
" Union" & _
" SELECT '(ALL)' As Bogus FROM tblAUTO_MASTER" & _
" ORDER BY 1"

but when I select "(ALL)" in the displayed combobox and click the 'go'
button which runs this code(below) the "(ALL)" does not get detected.
WHY? What I'm I missing??

If ctl.ItemsSelected.Count = 0 Then
MsgBox "You did not select any Phases, please try again.",
vbExclamation, "Ooooooops!"
Exit Sub
ElseIf ctl.ItemsSelected.Count = 1 Then
If ctl.ItemData(varItem) = "(ALL)" Then
strIN = " WHERE tblAUTO_MASTER.Section Like '*'"
Else
strIN = " WHERE tblAUTO_MASTER.Section='"
For Each varItem In ctl.ItemsSelected
strIN = strIN & ctl.ItemData(varItem) & "'"
Next varItem
End If

thanks
bobh.

May 21 '07 #1
3 1685
bobh wrote:
Hi All,

I've added an 'All' item to my combobox(below) and it does display as
the first item

If Me.cboLOB.Column(0) = "auto" Then
strSQL = "SELECT DISTINCT tblAUTO_MASTER.Section" & _
" FROM tblAUTO_MASTER" & _
" Union" & _
" SELECT '(ALL)' As Bogus FROM tblAUTO_MASTER" & _
" ORDER BY 1"

but when I select "(ALL)" in the displayed combobox and click the 'go'
button which runs this code(below) the "(ALL)" does not get detected.
WHY? What I'm I missing??

If ctl.ItemsSelected.Count = 0 Then
MsgBox "You did not select any Phases, please try again.",
vbExclamation, "Ooooooops!"
Exit Sub
ElseIf ctl.ItemsSelected.Count = 1 Then
If ctl.ItemData(varItem) = "(ALL)" Then
strIN = " WHERE tblAUTO_MASTER.Section Like '*'"
Else
strIN = " WHERE tblAUTO_MASTER.Section='"
For Each varItem In ctl.ItemsSelected
strIN = strIN & ctl.ItemData(varItem) & "'"
Next varItem
End If

thanks
bobh.
What's the value of varItem? Null?

Maybe
ElseIf ctl.ItemsSelected.Count = 1 Then
If Me.List0.ListIndex = 0 Then
strIN = " WHERE tblAUTO_MASTER.Section Like '*'"
Else
strIN = " WHERE tblAUTO_MASTER.Section='"
strIN = strIN & ctl.ItemData(ctl.ListIndex) & "'"
...or whatever code you want
endif
Endif

You can use Msgbox to see the values.
May 22 '07 #2
On May 21, 3:04 pm, bobh <vulca...@isp.comwrote:
Hi All,

I've added an 'All' item to my combobox(below) and it does display as
the first item

If Me.cboLOB.Column(0) = "auto" Then
strSQL = "SELECT DISTINCT tblAUTO_MASTER.Section" & _
" FROM tblAUTO_MASTER" & _
" Union" & _
" SELECT '(ALL)' As Bogus FROM tblAUTO_MASTER" & _
" ORDER BY 1"

but when I select "(ALL)" in the displayed combobox and click the 'go'
button which runs this code(below) the "(ALL)" does not get detected.
WHY? What I'm I missing??

If ctl.ItemsSelected.Count = 0 Then
MsgBox "You did not select any Phases, please try again.",
vbExclamation, "Ooooooops!"
Exit Sub
ElseIf ctl.ItemsSelected.Count = 1 Then
If ctl.ItemData(varItem) = "(ALL)" Then
strIN = " WHERE tblAUTO_MASTER.Section Like '*'"
Else
strIN = " WHERE tblAUTO_MASTER.Section='"
For Each varItem In ctl.ItemsSelected
strIN = strIN & ctl.ItemData(varItem) & "'"
Next varItem
End If

thanks
bobh.
Put a break in the code and find out what it thinks
ctl.ItemData(varItem) is when you select "(ALL)". That should tell
you what you need to trap for.

May 22 '07 #3
On May 21, 9:29 pm, salad <o...@vinegar.comwrote:
bobhwrote:
Hi All,
I've added an 'All' item to my combobox(below) and it does display as
the first item
If Me.cboLOB.Column(0) = "auto" Then
strSQL = "SELECT DISTINCT tblAUTO_MASTER.Section" & _
" FROM tblAUTO_MASTER" & _
" Union" & _
" SELECT '(ALL)' As Bogus FROM tblAUTO_MASTER" & _
" ORDER BY 1"
but when I select "(ALL)" in the displayed combobox and click the 'go'
button which runs this code(below) the "(ALL)" does not get detected.
WHY? What I'm I missing??
If ctl.ItemsSelected.Count = 0 Then
MsgBox "You did not select any Phases, please try again.",
vbExclamation, "Ooooooops!"
Exit Sub
ElseIf ctl.ItemsSelected.Count = 1 Then
If ctl.ItemData(varItem) = "(ALL)" Then
strIN = " WHERE tblAUTO_MASTER.Section Like '*'"
Else
strIN = " WHERE tblAUTO_MASTER.Section='"
For Each varItem In ctl.ItemsSelected
strIN = strIN & ctl.ItemData(varItem) & "'"
Next varItem
End If
thanks
bobh.

What's the value of varItem? Null?

Maybe
ElseIf ctl.ItemsSelected.Count = 1 Then
If Me.List0.ListIndex = 0 Then
strIN = " WHERE tblAUTO_MASTER.Section Like '*'"
Else
strIN = " WHERE tblAUTO_MASTER.Section='"
strIN = strIN & ctl.ItemData(ctl.ListIndex) & "'"
...or whatever code you want
endif
Endif

You can use Msgbox to see the values. - Hide quoted text -

- Show quoted text -
In debug mode the value being returned was 'null' so I changed the
code to this which fixed the problem

ElseIf ctl.ItemsSelected.Count = 1 Then
If Me.cboPhase.Column(0) = "(ALL)" Then
strIN = " WHERE tblAUTO_MASTER.Section Like '*'"
Else
strIN = " WHERE tblAUTO_MASTER.Section='"
For Each varItem In ctl.ItemsSelected
strIN = strIN & ctl.ItemData(varItem) & "'"
Next varItem
End If
Else 'user must have selected multiple values

bobh.

May 23 '07 #4

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

Similar topics

0
by: selowan | last post by:
Hi, In VB6 Pro SP5, I have a form that contains an MSFlexGrid and a few other textboxes and comboboxes. I am using the technique from MSDN article Q241355, which describes how to tab and edit in...
3
by: Tee | last post by:
Hi, I have few textboxes and combobox in a user control. How can I detect if a user has changed the value of combobox and the text in textbox? I know that textbox has a CanUndo property that...
4
by: piet | last post by:
Is it possible to add an option ALL in the ist of a combobox that get its values from a table? Example: in the combobox are the items from the table "days": monday, th.... The chosen value...
9
by: Hannu | last post by:
Hi. i have hundreds of queries and forms. I know there are a lot of forms and also queries that are not in use and could be deleted, but problem is how i know which are not in use? it is very...
3
by: google | last post by:
This is something I've done plenty of times in '97, but I can't seem to get it to work correctly in Access 2003. Say, for example, I have a form with an unbound combobox, the data source is a...
1
by: M Shafaat | last post by:
Hi! What is a good way to detect an editting change in a form with textboxes and other editable controls? Regards M Shafaat
9
by: Don | last post by:
Is there any way to detect when an item has been added to the Items collection of a combobox or listbox? I am inheriting a Combobox and want to validate items before they are added to the...
0
by: timbobd | last post by:
Using Visual Basic .NET 2003, I have created a combobox with custom code for "autocomplete" functionality and to trigger a DropDown event when the user starts typing. I want to do a database lookup...
6
by: Aziz | last post by:
Here's the problem. On my OrderForm the user can click a link to open up the AddCustomer form to add a new customer, when AddCustomer form closes, it saves the customer to the DataBase. The...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
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...

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.