adding to the listview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmrz
    New Member
    • May 2007
    • 9

    #1

    adding to the listview

    why x in this script return Nothing?!

    Dim x As ListItem
    Set x = lvList.ListItem s.Add(, , "" & (sRecordSource. Fields(0))), sNumIco, sNumIco)



    sRecordSource.F ields(0) has "300" Value. but x returns Nothing!
  • danp129
    Recognized Expert Contributor
    • Jul 2006
    • 323

    #2
    Code:
    Dim x As ListItem
    Set x = lvList.ListItems.Add(, , "" & (sRecordSource.Fields(0))[U][B])[/B][/U], sNumIco, sNumIco)
    There are too many closing parands after sRecordSource.F ields(0) not sure why it doesn't throw an error and highlight it for you... Maybe there was something there that you took out before posting? If there is, make sure you're not using "On Error Resume Next" while you're troubleshooting atleast.

    Anyways, it worked fine for me when I substituted your field value with "300" and I removed the extra parand...

    Code:
    Dim x As ListItem
    Set x = lvList.ListItems.Add(, , "" & ("300"), sNumIco, sNumIco)
    x.ListSubItems.Add , , "blah"
    Put this in the listview:
    300 blah

    Comment

    • mmrz
      New Member
      • May 2007
      • 9

      #3
      Originally posted by danp129
      Code:
      Dim x As ListItem
      Set x = lvList.ListItems.Add(, , "" & (sRecordSource.Fields(0))[U][B])[/B][/U], sNumIco, sNumIco)
      There are too many closing parands after sRecordSource.F ields(0) not sure why it doesn't throw an error and highlight it for you... Maybe there was something there that you took out before posting? If there is, make sure you're not using "On Error Resume Next" while you're troubleshooting atleast.

      Anyways, it worked fine for me when I substituted your field value with "300" and I removed the extra parand...

      Code:
      Dim x As ListItem
      Set x = lvList.ListItems.Add(, , "" & ("300"), sNumIco, sNumIco)
      x.ListSubItems.Add , , "blah"
      Put this in the listview:
      300 blah

      I commented the On Error Resume Next the naother error shows to me that is :
      Imagelist must be initialized before it can be used!

      Comment

      • danp129
        Recognized Expert Contributor
        • Jul 2006
        • 323

        #4
        Great :)
        Not sure if you need help with the image list but I haven't used them much so if you do need help tonight I'd google it

        Comment

        • danp129
          Recognized Expert Contributor
          • Jul 2006
          • 323

          #5
          Oh and if you don't have an image list because you're just using an example and don't require an icon then just remove the last two parameters.

          Comment

          • mmrz
            New Member
            • May 2007
            • 9

            #6
            Originally posted by danp129
            Oh and if you don't have an image list because you're just using an example and don't require an icon then just remove the last two parameters.

            Thanks alot :)

            Comment

            Working...