fields in listbox

Stefanw

Registered User.
Local time
Tomorrow, 00:16
Joined
Jan 15, 2007
Messages
20
Hi

I'm struggling with this one. I want the data from some fields entered on my form appear in a listbox. The following code isn't working at the moment. What's wrong?!?!:confused:

---------------------------
Private Sub Form_Load()
Dim lst1 As ListBox
Dim strMsg As String
Dim entity1 As String
Dim entity2 As String
Dim entity3 As String
Dim entity4 As String
Dim entity5 As String

entity1 = clients!entity1
entity2 = clients!entity2
entity3 = clients!entity3
entity4 = clients!entity4
entity5 = clients!entity5


Set lst1 = Me!lst1


' Fill List1.
With lst1
.RowSourceType = "Value List"
.RowSource = entity1
.RowSource = entity2
.RowSource = entity3
.RowSource = entity4
.RowSource = entity5
.ColumnCount = 1
End With
End Sub
---------------------
Thanks a lot...
 
With this -

.RowSource = entity1
.RowSource = entity2 'you just changed the rowsource from entity1 with entity2
.RowSource = entity3 'you just changed the rowsource from entity2 with entity3
.RowSource = entity4 'you get the idea
.RowSource = entity5 ' :)

all you are doing is replacing the rowsource with the next entity.

Try instead -

.AddItem = entity1

etc
 
Hi Jimma,

Gives compile error:
Argument not optional

I changed like you suggested the code into:
--------
With lst1
.RowSourceType = "Value List"
.AddItem = entity1
.AddItem = entity2
.AddItem = entity3
.AddItem = entity4
.AddItem = entity5
.ColumnCount = 1
End With
------
what could be wrong??
Thanks in advance
 
Doh, sorry was on autopilot, remove the =

.additem entity1
 
It works:) the only thing now is if for example entity5 is empty it gives the following error:

Invalid use of Null

is there some trick for avoiding this problem?!

thanks again.
 

Users who are viewing this thread

Back
Top Bottom