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?
COPUSERAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

danishaniCommented:
Try to reference the ListView directly like this:

  Dim rs As New ADODB.Recordset

    rs.MoveFirst
    Do While Not rs.EOF
        With Me.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"), "")
        End With
      rs.MoveNext
     Loop

Hope this helps,
Daniel
0
COPUSERAuthor Commented:
Daniel,

It was the first thing I did and it did not work.
0
danishaniCommented:
Check below thread and sample on the syntax:
http://support.microsoft.com/kb/155178

Hope this helps,
Daniel
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

danishaniCommented:
This is the more recent version of the same article:
http://support.microsoft.com/kb/210006

Hope this helps,
Daniel
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rockiroadsCommented:
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?
0
COPUSERAuthor Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.