Multi column list box additem

aman

Registered User.
Local time
Yesterday, 17:52
Joined
Oct 16, 2008
Messages
1,251
Hi guys

I am trying to add items in multi column list box but it just keeps on giving me compile error at additem statement.

Code:
Set rs=currentdb.openrecordset("qry_mysignoff")
Rs.movefirst
Do while not rs.eof

I=me.lstitems.lstcount-1
If isnull(rs.fields("datesign")) then
Me.lstitems
.columncount=3
.additem
.list(I,0)=rs.fields("Formname")
.list(I,1)=rs.fields("ActivityRef")
.list(I,2)=rs.fields("datesubmit")
End with
Rs.movenext
End if
 
. addtem rs. Fields("for name") & ";" & rs. Fields("activiityref") & ";" & rs..Fields("datesumit")
 
You do not have With Me.lstItems ?, yet you have an End With

Hi guys

I am trying to add items in multi column list box but it just keeps on giving me compile error at additem statement.

Code:
Set rs=currentdb.openrecordset("qry_mysignoff")
Rs.movefirst
Do while not rs.eof

I=me.lstitems.lstcount-1
If isnull(rs.fields("datesign")) then
Me.lstitems
.columncount=3
.additem
.list(I,0)=rs.fields("Formname")
.list(I,1)=rs.fields("ActivityRef")
.list(I,2)=rs.fields("datesubmit")
End with
Rs.movenext
End if
 
It still gives me argument not optional compiler error at .additem statement .

Code:
Set rs=currentdb.openrecordset("qry_mysignoff")
Rs.movefirst
Do while not rs.eof

I=me.lstitems.lstcount-1
If isnull(rs.fields("datesign")) then
With Me.lstitems
.columncount=3
.additem
.list(I,0)=rs.fields("Formname")
.list(I,1)=rs.fields("ActivityRef")
.list(I,2)=rs.fields("datesubmit")
End with
Rs.movenext
End if
Loop
 
Revise your code

Code:
...
...
...

Me.lstItems.ColumnCount = 3

Do While Not rs.EOF
	Me.lstItems.AddItem rs("FormName") & ";" & rs("ActivityRef") & ";" & rs("DateSubmit")
	rs.MoveNext
Loop
rs.Close
Set rs = Nothing

The Row Source Type of the listbox should be Value List
 
Last edited:

Users who are viewing this thread

Back
Top Bottom