Add blank line to listbox in Access 2007

svjensen

Registered User.
Local time
Today, 07:00
Joined
May 6, 2010
Messages
37
Our firm has recently switched to Access 2007 (i know that we are now in 2011 :)), and running my old 2003 applications I have run into a small problem.
Using VBA I write items to listsbox using .AddItem, and eventually I write an empty line using '.AddItem ""'.
But in Access 2007 this is interpreted as a blank column.

How do I insert a blank line in a listbox using VBA in Access 2007?
 
How about
.AddItem Null

I rarely use lists for listboxes. My favourite way lately is populating listboxes with a disconnected ADO Recordset.
 
The Null suggestion did not work, but I solved it using:

for i = 1 to .ColumnCount
strTempString = strTempString & ";"
next i
.AddItem strTempString

Maybe not pretty, but it works :-)
 
It looks to all the world that you have multiple columns.
If you do then it's only appropriate to add values per column - even in the AddItem method by concatenating the values with a semicolon separator.
If you were building the RowSource property string entirely manually you'd have to do the same, and that's basically all the AddItem method does - builds up that cconcatenated string list exactly as if you'd done so manually - hence the requirement that you position columns appropriately.
i.e. there's nothing wrong with what you've done - but nothing messy about it either, that's how it should be.

Cheers.
 

Users who are viewing this thread

Back
Top Bottom