Jumat, 06 September 2013

RE: [MS_AccessPros] ListView problem

 

Patricia-

 

Found this example on MSDN:

 

Private Sub Form_Load()

   Dim clmX As ColumnHeader

   Dim itmX As ListItem

   Dim i As Integer

 

   For i = 1 To 3

      Set clmX = ListView1.ColumnHeaders.Add()

      clmX.Text = "Col" & i

   Next i

  

   ' Add 10 items to list, all with the same icon

 

   For i = 1 To 10

      Set itmX = ListView1.ListItems.Add()

      itmX.SmallIcon = 1

      itmX.Text = "ListItem " & i

      itmX.SubItems(1) = "Subitem 1"

      itmX.SubItems(2) = "Subitem 2"

   Next i

End Sub

 

Looks like the Add method returns a ListItem object, then you can set its properties as you want.

 

And then I found this:

 

http://msdn.microsoft.com/en-us/library/aa443205(v=vs.60).aspx

 

Adds a ListItem object to a ListItems collection in a ListView control and returns a reference to the newly created object.

Syntax

object.Add(index, key, text, icon, smallIcon)

The Add method syntax has these parts:

Part

Description

object

Required. An object expression that evaluates to a ListItems collection.

index

Optional. An integer specifying the position where you want to insert the ListItem. If no index is specified, the ListItem is added to the end of the ListItems collection.

key

Optional. A unique string expression that can be used to access a member of the collection.

text

Optional. A string that is associated with the ListItem object control.

icon

Optional. An integer that sets the icon to be displayed from an ImageList control, when the ListView control is set to Icon view.

smallIcon

Optional. An integer that sets the icon to be displayed from an ImageList control, when the ListView control is set to SmallIcon view.

 

Looks like it is expecting a String, not a number.  Try wrapping a CStr call around rs(0).Value.

 

John Viescas, Author

Microsoft Access 2010 Inside Out

Microsoft Access 2007 Inside Out

Microsoft Access 2003 Inside Out

Building Microsoft Access Applications

SQL Queries for Mere Mortals

http://www.viescas.com/

(Paris, France)

 

 

 

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Patricia Mapes
Sent: Friday, September 06, 2013 5:09 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] ListView problem

 




I am working on Windows7, with MS Access 2010, on an app written in MS Access 2003.

 

I am trying to populate a ListView and I'm getting a "Error 13, Type Mismatch" error.

 

This is my code:

 

        For intCount1 = 1 To intTotCount
        If IsNumeric(rs(0).Value) Then
           ' Set NewLine = ListView0.ListItems.Add(, , Str(rs(0).Value))
           Set NewLine = ListView0.ListItems.Add(, , rs(0).Value)

 

(Fails on line above and throws error. Value is  a number.)
        Else
        
        Set NewLine = ListView0.ListItems.Add(, , rs(0).Name)
        End If
        For intCount2 = 1 To rs.Fields.Count - 1
            NewLine.SubItems(intCount2) = rs(intCount2).Value
            Next intCount2
        rs.MoveNext
        Next intCount1

 

I have looked at this long I am blank!

Thank you for your help.

--
Patricia Mapes

 




__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar