Results 1 to 3 of 3

Thread: What am I doing wrong?

  1. #1

    Thread Starter
    Addicted Member AmmerBow's Avatar
    Join Date
    Sep 2000
    Posts
    195

    Unhappy

    Everytime i test this code I get this message.
    "object variable or with block variable not set"
    data1 has been setup with all the right access db settings.
    but it is still not working.

    Code:
    Private Sub listviewUpdate()
    Dim itmRecord As ListItem
    
    With Data1.Recordset
        Do Until .EOF
            Set itmRecord = ListView1.ListItems.Add(, , .Fields("ProjName"))
            itmRecord.SubItems(1) = .Fields("FirstName")
            .MoveNext
        Loop
    End With
    End Sub

  2. #2
    Member
    Join Date
    Aug 2000
    Posts
    60
    AmmerBow,

    If you are calling your listviewUpdate procedure from the Form_Load event that is the problem, because the data control only initializes after the Form_Load has executed.

    What I normally do is to set a boolean variable in the Form_Load event to true, and then run the listviewUpdate in Form_Activate if that variable is true, as well as set the variable back to false, so that the listviewUpdate only runs once.

    This should solve your problem.
    Barend
    JHB-SA

    Nothing is impossible, except skiing through a revolving door.

  3. #3

    Thread Starter
    Addicted Member AmmerBow's Avatar
    Join Date
    Sep 2000
    Posts
    195
    Doh!
    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width