Results 1 to 3 of 3

Thread: ListView Question????

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Talking

    I am writing this search routine to find image files and display the filename in a list view. The code below to search is on frmSearch and the listview is on another form called frmMain.

    The error I am getting is "wrong number of arguments or invalid property assignment" and it focuses on this:

    lngCount = rs.Fields("Cat", "Title", "FileExtension", "FileName")

    What am I doing wrong?

    Code:
    Private Sub cmdSearch_Click()
            Dim conn As ADODB.Connection
                Set conn = New ADODB.Connection
            Dim rs As ADODB.Recordset
                Set rs = New ADODB.Recordset
            Dim sql As String
            Dim res As String
            Dim lngCount As Long
            Dim lngItem As Long
                   
            prgBar.Visible = True
            
            prgBar.Min = 0
            prgBar.Max = 10
            prgBar.Value = 10
            
            sql = "SELECT * FROM Master WHERE Master.Title = '" & txtTitle.Text & "' and Master.Cat = '" & txtCat.Text & "' and Master.FileExtension = '" & txtFE.Text & "' and Master.FileName = '" & txtIFN.Text & "'"
                
            conn.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & App.Path & "\dbGraphics.mdb;Persist Security Info=False"
            conn.CursorLocation = adUseClient
            conn.Open
            
            rs.Open sql, conn, adOpenStatic, adLockOptimistic
            lngCount = rs.Fields("Cat", "Title", "FileExtension", "FileName")
                        
            If rs.EOF Then
                MsgBox "No files found for the search criteria.", vbOKOnly, "Search Results"
            Else
               For lngItem = 1 To lngCount
                'Adds the item to the list
                frmMain.lvwResults.ListItems.Add , , rs!Cat
                'Adds the ListSubItem of the first item added
                frmMain.lvwResults.ListItems(lngItem).ListSubItems.Add , , rs!Title
               Next
            End If
        
            
            rs.Close
            conn.Close
        
            Set rs = Nothing
            Set conn = Nothing
        
    
    End Sub

  2. #2
    Addicted Member LiquidRezin's Avatar
    Join Date
    Dec 2000
    Location
    Aliso Viejo, CA
    Posts
    176
    Originally posted by jesus4u
    [B]I am writing this search routine to find image files and display the filename in a list view. The code below to search is on frmSearch and the listview is on another form called frmMain.

    The error I am getting is "wrong number of arguments or invalid property assignment" and it focuses on this:

    lngCount = rs.Fields("Cat", "Title", "FileExtension", "FileName")

    What am I doing wrong?
    rs.fields("cat") thats all you can do
    fields only takes one parameter
    Ah read ur *****scope and eat some *****durrrvs!

  3. #3
    Addicted Member LiquidRezin's Avatar
    Join Date
    Dec 2000
    Location
    Aliso Viejo, CA
    Posts
    176
    what are you trying to do with lngcount anyway? get the count of the fields? cuz if you are u should use lngcount = whatever.fields.count
    that'll tell you how many fields you have
    Ah read ur *****scope and eat some *****durrrvs!

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