Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListView Control to search a directory

Status
Not open for further replies.

babyJebus

Programmer
Jan 25, 2007
8
GB
I need a ListView control in Microsoft Access to search for an Excel file, and select a file to perform actions on such as importing it into the database.

Any of you guys know if this can be done, and if so how to do it.

 
You can do it with listbox easily. There should be many examples here.

Here is an example with ListView.
Code:
Private Sub Form_Load()
    Dim sPath As String
    Dim sFile As String

    'Change this path as required
    sPath = "C:\Excel Files\"
    sFile = Dir(sPath, vbDirectory)

    With Me.ListView0
        .View = lvwReport
        .ListItems.Clear
        .ColumnHeaders.Clear
    End With

    With Me.ListView0.ColumnHeaders
        .Add , , "File Name", Me.ListView0.Width - 100, lvwColumnLeft
    End With

    Do While sFile <> ""
        If Right(sFile, 4) = ".xls" Then
            With Me.ListView0
                Dim itmx As ListItem
                Set itmx = ListView0.ListItems.Add(, , sFile)
            End With
        End If
        sFile = Dir
    Loop
End Sub
To get selected name from the list see faq702-6026.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top