Results 1 to 2 of 2
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ERROR typ mismatch (2000)

    have errror in .text when code add rs:
    Function Create_Recordset(ListView1 As ListView) As ADODB.Recordset

    On Error GoTo error_function

    Dim iRow As Long
    Dim item As ListItem
    Dim iCol As Long

    Dim rs As Recordset
    With ListView1
    For iCol = 1 To ListView1.ColumnHeaders.Count - 1
    rs.Fields.Append .ColumnHeaders(iCol ).Text , adVarChar, 20
    'rs.Fields.Append .ColumnHeaders(iCol), , adVarChar, 250
    Next
    End With

    'rs.Open
    With rs

    For iRow = 1 To ListView1.ListItems.Count - 1
    Set item = ListView1.ListItems(iRow)

    .AddNew

    .Fields(0).value = item.Text

    For iCol = 1 To ListView1.ColumnHeaders.Count - 1
    .Fields(iCol).value = item.SubItems(iCol)
    Next
    Next

    End With

    Set Create_Recordset = rs

    Exit Function

    error_function:

    MsgBox Err.Description, vbCritical

    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ERROR typ mismatch (2000)

    Why are you filling a recordset from a listview? It's usually the other way round.

    Anyway, I think you'd have to use

    Dim rs As New Recordset

Posting Permissions

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