Solved

# List Box Row Source Type

Posted on 2004-04-19
Medium Priority
586 Views
If the Row Source Type of a listbox is set to Value List, what is the maximum length of the semi-colon separated string in the Row Source property?

Thanks
0
Question by:dds110
• 4
• 4
• 3

LVL 44

Accepted Solution

Arthur_Wood earned 200 total points
ID: 10862802
2048 characters, counting EVERY character in the string.

AW
0

LVL 44

Expert Comment

ID: 10862864
I may be remembering that number incorrectly.  It might be 1024.
0

LVL 8

Expert Comment

ID: 10863171
The limit for a listbox rowsource is 32,750 characters.  And like Arthur says, that's counting every character.
0

LVL 8

Author Comment

ID: 10865403
hhmmmm!
2048, 1024, 32,750

Seems to be some disagreement going on here.

I guess I'll write me a function that adds 1 character at a time to the row source and see when it breaks.  Sad to think I didn't think of that earlier.

I'll award the points to whoever is closest.  This like that game my dad used to play with me and my sister....pick a number between 1 and 10...whoever is closest doesn't have to do the dishes.

=-)

See ya later.
0

LVL 44

Expert Comment

ID: 10865686
I am pretty sure thsat the number is 2048, but it has been about 2 years since I encountered the issue (with Access 97).  And Mourdekai could be refering to Access 2003, which may in fact have raised the limit, though I would find the quoted number to be a bit hard to accept (if it is that large, then the correct value would be 32767, not 32750).

AW
0

LVL 8

Author Comment

ID: 10868208
OK

Here's my code:  And I failed to mention that I am using ACC97 (sorry about that).

Private Sub Command2_Click()
On Error GoTo errline:
Me.List0.RowSource = ""
Dim x As Long
For x = 1 To 50000
Me.List0.RowSource = Me.List0.RowSource & "A"
Next
exitline:
Exit Sub
errline:
MsgBox x
MsgBox Err.Description, , Err.Number
Resume exitline:
End Sub

It threw an error when x was equal to 2049.  So aw get's the points.

However.  To be fair and all, I will try this code out at home later tonight to test Mourdekai's answer.  If it's good, I'll post a new question for you with the same amount of points.

Thanks to all.
0

LVL 8

Expert Comment

ID: 10868615
My number came from the specifications for Access 2002.  I agree Arthur that the number looks a little strange not being a power of 2.  But the specifications in help say the limit is 32750 for a sql statement used in a rowsource for a control.  I wrote some code like dds110 did and I got the error after 32750.

Don't worry about posting another question for points,
0

LVL 8

Author Comment

ID: 10871113
No dude, you deserve them.  I have no problem with it.  I asked a question, and got an answer.  I'm still gonna post the points.

I'm a giving kind of guy!

=-)

Besides, what I'm working on will have to be done in Access 2000 and Up anyway.
0

LVL 44

Expert Comment

ID: 10871306
Mordekai, the precise statement says:

"Number of characters in an SQL statement that serves as the Recordsource or Rowsource property of a form, report, or control (both .mdb and .adp) " as 32750.

The key phrase here being:"in an SQL statement".  that is NOT what we are talking about here.  What dds110 is asking about the number of characters allowed in a VALUE LIST.  When the RowSourceType is set to "Table/Query", the query string is in fact passed to the JET engine to be executed against the database, while when the RowSourceType is "Value List", the value list itself must be parsed by the underlying VB engine, and there lies the rub.  The string from the RowSource field is passed to an internal variable, and that is limited to 1 code page (hence the 2048 character limit) .  They are NOT the same thing.

dds110-->By the way, you need to be aware of a MINOR 'gotcha' - when it comes to parsing the RowSource string.  The HELP systems says that the 'separator' between fields is the ';' (semi-colon character).  However, you will discover that the ',' (COMMA) is also treated as a field separator, ansd that will cause you great headaches if you attempt to have text, in the field values, that has legitimate embedded ',' characters. !!!!

That DOES NOT apply it the fields are coming from the output of an SQL query.

AW

0

LVL 8

Expert Comment

ID: 10871443
Arthur,

I know we are talking about the value list.  In Access 2002, the limit for a value list IS 32750 characters.  I know the help file says 'SQL statement', but the character limit still applies for the rowsource property when the rowsourcetype is value list.  It just doesn't send it to the JET engine.

If you have Access 2002 you can check it with code like dds110 posted above.  It will throw an error as soon as you try to put a string of length 32751 in the rowsource.  I don't know about any earlier versions, but 2002 has the 32750 limit.

Mourdekai

dds110,
You really don't need to post another Q for points.  I might be mistaken, but I don't think Points For... Q's are allowed anymore.
0

LVL 8

Author Comment

ID: 10877526
OK, no problem guys.  I'm still gonna test it with XP though.  I'll let you know in here how it goes.  Acc2000 limited me to 2048.

AW, i figured out the comma thing yesterday.  What a pain.  Anyway, after all of this, I had to change my direction with the list box anyway and use a table for the rowsource.  But not all of this was in vain.  I learned something new =-)

See ya later.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
When we develop an application in Ms Access 2016 we should also try to protect the queries, macros and table links. I know I may not have a permanent solution but for novice users, they will not manage to break your application. Below is the detail …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
###### Suggested Courses
Course of the Month9 days, 10 hours left to enroll