Creating a Browse Button on an Access Form VBA

Posted on 2008-11-13
Last Modified: 2013-11-28
I am trying to create a simple "browse" button in which it opens a directory tree and filters images (.jpg or .bmp) out of it. I started coding it below but it is complaining that "dlg.SelectedItems" is not optional. Can someone help me fix this and add the filters to this code as well. Also after selecting the the image from the directory how can I display that image on the form? I will have the path, is there some control that I can add to my Access form to display it?

Thanks in Advance
Option Compare Database

Option Explicit

Private Sub btnBrowse_Click()

Dim dlg As FileDialog

    Dim strFilePath As String

    Set dlg = Application.FileDialog(msoFileDialogFolderPicker)


        If dlg.Show = -1 Then


            strFilePath = dlg.SelectedItems

        End If



    Set dlg = Nothing


    txtPath = strFilePath

End Sub

Open in new window

Question by:npl77
    1 Comment
    LVL 3

    Accepted Solution

    Perhaps this will help.  The second example more specifically.

    Maybe someone can provide a better answer :)

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now