473,763 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange List Box Behavior

JvC
Background
Access 2003. MDB Front End.
I am populating a list box with the names of queries in the system. I
am searching for strings in the query names and then creating a value
list for users to select from.

Problem
My users occasionally use commas in query names. When I move the value
list to the RowSource of the list box, the commas in the names are
being interpreted as list separators. If my RowSource is:
Comma, delimited, query;SecondQue ry

In the list box I should get:

Comma, delimited, query
SecondQuery

What I actuall get is:
Comma
Delimited
Query
SecondQuery

Is this a bug, or some fascinating quirk that I can work around?

Thanks!

John
Aug 15 '08 #1
5 1685
"JvC" <jo******@earth link.netwrote in message
news:k4******** **********@news fe06.iad...
Background
Access 2003. MDB Front End.
I am populating a list box with the names of queries in the system. I am
searching for strings in the query names and then creating a value list
for users to select from.

Problem
My users occasionally use commas in query names. When I move the value
list to the RowSource of the list box, the commas in the names are being
interpreted as list separators. If my RowSource is:
Comma, delimited, query;SecondQue ry

In the list box I should get:

Comma, delimited, query
SecondQuery

What I actuall get is:
Comma
Delimited
Query
SecondQuery

Is this a bug, or some fascinating quirk that I can work around?

Thanks!

John
It's a fascinating quirk. The comma is used as a row delimiter as you found.
No way to switch this off (AFAIK).

What you can do for a workaround is use the replace function to transform
all commas into (say) slashes:

strTemp = "Comma, delimited, query;SecondQue ry"
Listbox.RowSour ce = Replace(strTemp , ",", "/")

Then, following user selection, use Replace again to transform them back
into commas.
Aug 15 '08 #2
JvC
I got so frustrated I wrote it out to a table. I need the users to be
able to double click on the query and run it. Simpler to do if the name
is correct!

Thanks for the input!

John

It happens that Stuart McCall formulated :
"JvC" <jo******@earth link.netwrote in message
news:k4******** **********@news fe06.iad...
>Background
Access 2003. MDB Front End.
I am populating a list box with the names of queries in the system. I am
searching for strings in the query names and then creating a value list for
users to select from.

Problem
My users occasionally use commas in query names. When I move the value list
to the RowSource of the list box, the commas in the names are being
interpreted as list separators. If my RowSource is:
Comma, delimited, query;SecondQue ry

In the list box I should get:

Comma, delimited, query
SecondQuery

What I actuall get is:
Comma
Delimited
Query
SecondQuery

Is this a bug, or some fascinating quirk that I can work around?

Thanks!

John

It's a fascinating quirk. The comma is used as a row delimiter as you found.
No way to switch this off (AFAIK).

What you can do for a workaround is use the replace function to transform all
commas into (say) slashes:

strTemp = "Comma, delimited, query;SecondQue ry"
Listbox.RowSour ce = Replace(strTemp , ",", "/")

Then, following user selection, use Replace again to transform them back into
commas.

Aug 15 '08 #3
JvC wrote:
I got so frustrated I wrote it out to a table. I need the users to be
able to double click on the query and run it. Simpler to do if the name
is correct!

Thanks for the input!

John

It happens that Stuart McCall formulated :
>"JvC" <jo******@earth link.netwrote in message
news:k4******* ***********@new sfe06.iad...
>>Background
Access 2003. MDB Front End.
I am populating a list box with the names of queries in the system. I
am searching for strings in the query names and then creating a value
list for users to select from.

Problem
My users occasionally use commas in query names. When I move the
value list to the RowSource of the list box, the commas in the names
are being interpreted as list separators. If my RowSource is:
Comma, delimited, query;SecondQue ry

In the list box I should get:

Comma, delimited, query
SecondQuery

What I actuall get is:
Comma
Delimited
Query
SecondQuery

Is this a bug, or some fascinating quirk that I can work around?

Thanks!

John


It's a fascinating quirk. The comma is used as a row delimiter as you
found. No way to switch this off (AFAIK).

What you can do for a workaround is use the replace function to
transform all commas into (say) slashes:

strTemp = "Comma, delimited, query;SecondQue ry"
Listbox.RowSou rce = Replace(strTemp , ",", "/")

Then, following user selection, use Replace again to transform them
back into commas.
Have you considered a UDF function to populate the listbox? Instead of
ValueList, enter
FillList0
in the rowsource type row of the property sheet. Then copy the
following code into your module. To test, I placed a comma in the 4th
position of each query listed. Remove that code after you test it.

Option Compare Database
Option Explicit

Private Type ListQ
Qname As String
End Type
Private Function FillList0(fld As Control, ID As Variant, row As
Variant, col As Variant, Code As Variant) As Variant
On Error Resume Next

'DLE = Directory List External

Static strRows() As ListQ
Static Entries As Integer

Dim ReturnVal As Variant
Dim qdf As QueryDef

ReturnVal = Null

Select Case Code
Case acLBInitialize ' Initialize.
'Docmd.Hourglas s true
Dim rstFilter As Recordset

Entries = 0
ReDim Preserve strRows(Entries )

strRows(Entries ).Qname = "Query Name"

For Each qdf In CurrentDb.Query Defs
If Left(qdf.Name, 1) <"~" Then
Entries = Entries + 1
ReDim Preserve strRows(Entries )
strRows(Entries ).Qname = Left(qdf.Name, 3) & "," & _
Mid(qdf.Name, 4)
End If
Next qdf
ReturnVal = True
Case acLBOpen ' Open.
ReturnVal = Timer ' Generate unique ID for control.
Case acLBGetRowCount ' Get number of rows.
ReturnVal = Entries + 1
Case acLBGetColumnCo unt ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWi dth ' Column width.
ReturnVal = -1 ' -1 forces use of default width.
Case acLBGetValue ' Get data.
Select Case col
Case 0
ReturnVal = strRows(row).Qn ame
End Select
Case acLBEnd ' End.
Erase strRows
End Select
FillList0 = ReturnVal
End Function

Aug 15 '08 #4
JvC
Very nice!

Salad used his keyboard to write :
JvC wrote:
>I got so frustrated I wrote it out to a table. I need the users to be able
to double click on the query and run it. Simpler to do if the name is
correct!

Thanks for the input!

John

It happens that Stuart McCall formulated :
>>"JvC" <jo******@earth link.netwrote in message
news:k4****** ************@ne wsfe06.iad...

Background
Access 2003. MDB Front End.
I am populating a list box with the names of queries in the system. I am
searching for strings in the query names and then creating a value list
for users to select from.

Problem
My users occasionally use commas in query names. When I move the value
list to the RowSource of the list box, the commas in the names are being
interprete d as list separators. If my RowSource is:
Comma, delimited, query;SecondQue ry

In the list box I should get:

Comma, delimited, query
SecondQuer y

What I actuall get is:
Comma
Delimited
Query
SecondQuer y

Is this a bug, or some fascinating quirk that I can work around?

Thanks!

John
It's a fascinating quirk. The comma is used as a row delimiter as you
found. No way to switch this off (AFAIK).

What you can do for a workaround is use the replace function to transform
all commas into (say) slashes:

strTemp = "Comma, delimited, query;SecondQue ry"
Listbox.RowSo urce = Replace(strTemp , ",", "/")

Then, following user selection, use Replace again to transform them back
into commas.
Have you considered a UDF function to populate the listbox? Instead of
ValueList, enter
FillList0
in the rowsource type row of the property sheet. Then copy the following
code into your module. To test, I placed a comma in the 4th position of each
query listed. Remove that code after you test it.

Option Compare Database
Option Explicit

Private Type ListQ
Qname As String
End Type
Private Function FillList0(fld As Control, ID As Variant, row As Variant, col
As Variant, Code As Variant) As Variant
On Error Resume Next

'DLE = Directory List External

Static strRows() As ListQ
Static Entries As Integer

Dim ReturnVal As Variant
Dim qdf As QueryDef

ReturnVal = Null

Select Case Code
Case acLBInitialize ' Initialize.
'Docmd.Hourglas s true
Dim rstFilter As Recordset

Entries = 0
ReDim Preserve strRows(Entries )

strRows(Entries ).Qname = "Query Name"

For Each qdf In CurrentDb.Query Defs
If Left(qdf.Name, 1) <"~" Then
Entries = Entries + 1
ReDim Preserve strRows(Entries )
strRows(Entries ).Qname = Left(qdf.Name, 3) & "," & _
Mid(qdf.Name, 4)
End If
Next qdf
ReturnVal = True
Case acLBOpen ' Open.
ReturnVal = Timer ' Generate unique ID for control.
Case acLBGetRowCount ' Get number of rows.
ReturnVal = Entries + 1
Case acLBGetColumnCo unt ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWi dth ' Column width.
ReturnVal = -1 ' -1 forces use of default width.
Case acLBGetValue ' Get data.
Select Case col
Case 0
ReturnVal = strRows(row).Qn ame
End Select
Case acLBEnd ' End.
Erase strRows
End Select
FillList0 = ReturnVal
End Function

Aug 15 '08 #5
JvC wrote:
Very nice!
Thanks. I found some of my more complex queries would take a couple of
seconds to requery or present themselves initially. Using a UDF speeded
up the process dramatically. They're a bit more work but at times worth
the effort...especi ally the speed gains.

Value lists are useful for small sets of data but one can rapidly go
beyond the string length limit of a value list.

BTW, I set it up in my code to use a column heading as my first row.
>
Salad used his keyboard to write :
>JvC wrote:
>>I got so frustrated I wrote it out to a table. I need the users to be
able to double click on the query and run it. Simpler to do if the
name is correct!

Thanks for the input!

John

It happens that Stuart McCall formulated :

"JvC" <jo******@earth link.netwrote in message
news:k4***** *************@n ewsfe06.iad...

Backgroun d
Access 2003. MDB Front End.
I am populating a list box with the names of queries in the system.
I am searching for strings in the query names and then creating a
value list for users to select from.
>
Problem
My users occasionally use commas in query names. When I move the
value list to the RowSource of the list box, the commas in the
names are being interpreted as list separators. If my RowSource is:
Comma, delimited, query;SecondQue ry
>
In the list box I should get:
>
Comma, delimited, query
SecondQue ry
>
What I actuall get is:
Comma
Delimited
Query
SecondQue ry
>
Is this a bug, or some fascinating quirk that I can work around?
>
Thanks!
>
John

It's a fascinating quirk. The comma is used as a row delimiter as
you found. No way to switch this off (AFAIK).

What you can do for a workaround is use the replace function to
transform all commas into (say) slashes:

strTemp = "Comma, delimited, query;SecondQue ry"
Listbox.RowS ource = Replace(strTemp , ",", "/")

Then, following user selection, use Replace again to transform them
back into commas.

Have you considered a UDF function to populate the listbox? Instead
of ValueList, enter
FillList0
in the rowsource type row of the property sheet. Then copy the
following code into your module. To test, I placed a comma in the 4th
position of each query listed. Remove that code after you test it.

Option Compare Database
Option Explicit

Private Type ListQ
Qname As String
End Type
Private Function FillList0(fld As Control, ID As Variant, row As
Variant, col As Variant, Code As Variant) As Variant
On Error Resume Next

'DLE = Directory List External

Static strRows() As ListQ
Static Entries As Integer

Dim ReturnVal As Variant
Dim qdf As QueryDef

ReturnVal = Null

Select Case Code
Case acLBInitialize ' Initialize.
'Docmd.Hourglas s true
Dim rstFilter As Recordset

Entries = 0
ReDim Preserve strRows(Entries )

strRows(Entries ).Qname = "Query Name"

For Each qdf In CurrentDb.Query Defs
If Left(qdf.Name, 1) <"~" Then
Entries = Entries + 1
ReDim Preserve strRows(Entries )
strRows(Entries ).Qname = Left(qdf.Name, 3) & "," & _
Mid(qdf.Name, 4)
End If
Next qdf
ReturnVal = True
Case acLBOpen ' Open.
ReturnVal = Timer ' Generate unique ID for
control.
Case acLBGetRowCount ' Get number of rows.
ReturnVal = Entries + 1
Case acLBGetColumnCo unt ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWi dth ' Column width.
ReturnVal = -1 ' -1 forces use of default
width.
Case acLBGetValue ' Get data.
Select Case col
Case 0
ReturnVal = strRows(row).Qn ame
End Select
Case acLBEnd ' End.
Erase strRows
End Select
FillList0 = ReturnVal
End Function


Aug 15 '08 #6

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

Similar topics

2
1659
by: simon place | last post by:
while playing about with inheriting from list to be able to cache macro properties i noticed this, the rate of summing a list seems to be over linear? its nearly 3 times faster to sum the sums of smaller lists? from time import clock l=range(0,1000000)
2
1286
by: Panard | last post by:
Hi! Can anyone explain this to me : $ cat test.py l = d = { 'list' : l } for x in l : print "rm", x d.remove( x )
0
1709
by: thulsey | last post by:
Hi all, I've got some strange behavior happening in Firefox and Safari (Khtml and Gecko) that displays *almost* fine in IE6.0 (still trying to get pixels to line up, anal anal anal...) To speed things up, and to avoid any problems with looking through the css file, I'll say first that I based the navigation menu on the "Suckerfish Dropdown menu" online demo over at htmldog. (http://www.htmldog.com/articles/suckerfish/dropdowns/). In...
2
1539
by: Bruno van Dooren | last post by:
Hi All, i have some (3) different weird pointer problems that have me stumped. i suspect that the compiler behavior is correct because gcc shows the same results. ---------------------------------------------- //example 1: typedef int t_Array; int main(int argc, char* argv)
7
1053
by: akameswaran | last post by:
Ok, I am confused about this one. I'm not sure if it's a bug or a feature.. but >>> ================================ RESTART >>> f1 = open('word1.txt') >>> f2 = open('word2.txt') >>> f3 = open('word3.txt') >>> print >>> l1 =
2
287
by: Antonio | last post by:
Good morning, everyone. Here is the strange behavior: I have a datagrid (dgPIs) with paging enabled. When I click to view any page in the grid, it runs the private void lnkIPReg method, instead of the private void IPchangePage. The lnkIPReg method refers to a linkbutton that I created in the grid. The datagrid properties list the ItemCommand = lnkIPReg and the PageIndexChange
3
1518
by: sara | last post by:
Very strange behavior, but I suspect some is A2K and some might be for me to correct. Just trying to see if anyone can help and advise. We have a database that's been running for a few years with no problems. We continuously add queries and reports. We're up to about 700 queries (no, not all are used and most are parameter queries - the business asks a LOT of questions!), and under 250 reports and fewer than 15 forms. Data is...
8
3218
by: FBM | last post by:
Hi there, I am puzzled with the behavior of my code.. I am working on a networking stuff, and debugging with eclipse (GNU gdb 6.6-debian).. The problem I am experiencing is the following: Whenever I declare the sockaddr_in structure inside the main, the debugger crashes at line X*, not being able to access argv parameters (see code below). It is very strange.. by only being there, sockaddr_in does not allow me to question argc...
3
3598
by: TC | last post by:
I have a form which I'd like to display as a sizable dialog box. The behavior I get when I use FormBorderStyle = SizableToolWindow is perfect. However, when I use that option, the title bar of my form gets much smaller. The discrepancy really stands out, and looks like a bug. I anticipate that someone will tell me that the different title bar is intentional -- that showing a different title bar is Windows' way of visually distinguishing...
20
2238
by: Pilcrow | last post by:
This behavior seems very strange to me, but I imagine that someone will be able to 'explain' it in terms of the famous C standard. -------------------- code ----------------------------------- #include <stdio.h> int main (void) { char xx="abcd"; char * p1 = xx;
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10145
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9998
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.