COPUSER
asked on
MS Access ListView Control not working
Experts,
I have a form with a ListView control on it. Whenever I run the code to load the listview, I get the error 380 "Invalid Property value". The code is listed below.
Dim rs As New ADODB.Recordset
Dim lstItem As ListItem
rs.MoveFirst
Do While Not rs.EOF
Set lstItem = MyListView.ListItems.Add()
lstItem.Text = rs.Fields("StudyID")
lstItem.SubItems(1) = rs.Fields("StudyName")
lstItem.SubItems(2) = Nz(rs.Fields("StudyMonth") , "")
lstItem.SubItems(3) = Nz(rs.Fields("StudyYear"), "")
rs.MoveNext
Loop
I've tried both re-register mscomctl.ocx and reinstall mscomctl.ocx but nothing worked.
Can anyone shed some light on this?
I have a form with a ListView control on it. Whenever I run the code to load the listview, I get the error 380 "Invalid Property value". The code is listed below.
Dim rs As New ADODB.Recordset
Dim lstItem As ListItem
rs.MoveFirst
Do While Not rs.EOF
Set lstItem = MyListView.ListItems.Add()
lstItem.Text = rs.Fields("StudyID")
lstItem.SubItems(1) = rs.Fields("StudyName")
lstItem.SubItems(2) = Nz(rs.Fields("StudyMonth")
lstItem.SubItems(3) = Nz(rs.Fields("StudyYear"),
rs.MoveNext
Loop
I've tried both re-register mscomctl.ocx and reinstall mscomctl.ocx but nothing worked.
Can anyone shed some light on this?
ASKER
Daniel,
It was the first thing I did and it did not work.
It was the first thing I did and it did not work.
Check below thread and sample on the syntax:
http://support.microsoft.com/kb/155178
Hope this helps,
Daniel
http://support.microsoft.com/kb/155178
Hope this helps,
Daniel
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I assume that is just a snippet of the code as I do not see where you open the recordset
when you said you tried registering the ocx, did it come up as dll succeeded?
if you do not get any errors for that control when opening the form then it should of been registered fine
which line is it failing on, did u try place a break point then step thru?
when you said you tried registering the ocx, did it come up as dll succeeded?
if you do not get any errors for that control when opening the form then it should of been registered fine
which line is it failing on, did u try place a break point then step thru?
ASKER
I figured out why the listview control was not loading properly. I relied on the column heading setting I placed on the ListViewCtrlObject properties page. When I explicitly set the column heading properties via code, the rest of the code worked without a glitch. I still don't know why setting column header properties via control's property setting page will not work. Thanks for all the comments.
Dim rs As New ADODB.Recordset
rs.MoveFirst
Do While Not rs.EOF
With Me.MyListView.ListItems.Ad
lstItem.Text = rs.Fields("StudyID")
lstItem.SubItems(1) = rs.Fields("StudyName")
lstItem.SubItems(2) = Nz(rs.Fields("StudyMonth")
lstItem.SubItems(3) = Nz(rs.Fields("StudyYear"),
End With
rs.MoveNext
Loop
Hope this helps,
Daniel