473,396 Members | 2,037 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,396 software developers and data experts.

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;SecondQuery

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 1668
"JvC" <jo******@earthlink.netwrote in message
news:k4******************@newsfe06.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;SecondQuery

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;SecondQuery"
Listbox.RowSource = 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******@earthlink.netwrote in message
news:k4******************@newsfe06.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;SecondQuery

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;SecondQuery"
Listbox.RowSource = 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******@earthlink.netwrote in message
news:k4******************@newsfe06.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;SecondQuery

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;SecondQuery"
Listbox.RowSource = 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.Hourglass true
Dim rstFilter As Recordset

Entries = 0
ReDim Preserve strRows(Entries)

strRows(Entries).Qname = "Query Name"

For Each qdf In CurrentDb.QueryDefs
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 acLBGetColumnCount ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWidth ' Column width.
ReturnVal = -1 ' -1 forces use of default width.
Case acLBGetValue ' Get data.
Select Case col
Case 0
ReturnVal = strRows(row).Qname
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******@earthlink.netwrote in message
news:k4******************@newsfe06.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;SecondQuery

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;SecondQuery"
Listbox.RowSource = 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.Hourglass true
Dim rstFilter As Recordset

Entries = 0
ReDim Preserve strRows(Entries)

strRows(Entries).Qname = "Query Name"

For Each qdf In CurrentDb.QueryDefs
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 acLBGetColumnCount ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWidth ' Column width.
ReturnVal = -1 ' -1 forces use of default width.
Case acLBGetValue ' Get data.
Select Case col
Case 0
ReturnVal = strRows(row).Qname
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...especially 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******@earthlink.netwrote in message
news:k4******************@newsfe06.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;SecondQuery
>
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;SecondQuery"
Listbox.RowSource = 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.Hourglass true
Dim rstFilter As Recordset

Entries = 0
ReDim Preserve strRows(Entries)

strRows(Entries).Qname = "Query Name"

For Each qdf In CurrentDb.QueryDefs
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 acLBGetColumnCount ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWidth ' Column width.
ReturnVal = -1 ' -1 forces use of default
width.
Case acLBGetValue ' Get data.
Select Case col
Case 0
ReturnVal = strRows(row).Qname
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
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...
2
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
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...
2
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. ...
7
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 =...
2
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,...
3
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...
8
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: ...
3
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...
20
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 -----------------------------------...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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...

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.