Link to home
Start Free TrialLog in
Avatar of dds110
dds110

asked on

List Box Row Source Type

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
ASKER CERTIFIED SOLUTION
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I may be remembering that number incorrectly.  It might be 1024.
Avatar of Mourdekai
Mourdekai

The limit for a listbox rowsource is 32,750 characters.  And like Arthur says, that's counting every character.
Avatar of dds110

ASKER

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.
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
Avatar of dds110

ASKER

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.
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,
Avatar of dds110

ASKER

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.
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

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.
Avatar of dds110

ASKER

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.