what do i use in access 2000 to get a file open dialog box ??

Posted on 2006-04-12
Last Modified: 2011-09-20
hi guys,
in my access 2003 application, i use the following to get a file open dialog, but it does not work in access 2000.
does anyone have some code to replace what i am currently using ?

here is the code in access 2003, i need code for access 2000.

Sub getfilename()
     ' Displays the Office File Open dialog to choose a file name
    ' for the current employee record.  If the user selects a file
    ' display it in the image control.
    Dim fileName As String
    Dim result As Integer
    With Application.FileDialog(msoFileDialogFilePicker)
        .Title = "Select The FoundationCrawlSpace Picture"
        .Filters.Add "All Files", "*.*"
        .Filters.Add "JPEGs", "*.jpg"
        '.Filters.Add "Bitmaps", "*.bmp"
        .FilterIndex = 3
        .AllowMultiSelect = False
        .InitialFileName = CurrentProject.path
        result = .Show
        If (result <> 0) Then
            fileName = Trim(.SelectedItems.Item(1))
            Me![ImagePath].Visible = True
            Me![ImagePath].Text = fileName
            Me![Photo1].Value = -1
            Form_FoundationCrawlSpace.ImageFrame.Visible = True
            Form_FoundationCrawlSpace.ImagePath.Visible = False
        End If
    End With

End Sub
Question by:kevinsrea
    LVL 61

    Expert Comment

    What error do you get trying to run this code?  Is it possible that you have missing references in your Access 2000 application?  Open a VBA module and got to Tools -> References and verify that nothing is labeled MISSING.  If you do have missing references, you will need to update  them with the correct version.

    You can also try this API File open function... It has worked well for me in regardless of Access Version:
    LVL 61

    Assisted Solution

    To clarify what you need to do for the code at that URL...

    Copy everything between these two lines  and paste in a module, called for  example modDirectorysearch

    '***************** Code Start **************

    '************** Code End *****************

    Then to get a filename from the windows file open dialog, just call it like this:

    dim strFileName as string
    strFileName = ahtCommonFileOpenSave( _
                    OpenFile:=True, _
                    DialogTitle:="Please select an input file...", _


    Author Comment

    the reason the access 2003 code that i have does not work, is that the routine was not available to access 2000.

    LVL 61

    Expert Comment

    Give the API code at the URL I posted a try.  That should work for you.

    Author Comment

    ok,, it seems to be working.., how do i modify the code so it just looks for the filetype   .jpg and   .gif ?



    LVL 17

    Accepted Solution

    substitute the following line
    strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")

    with these two lines
    strFilter = ahtAddFilterItem(strFilter, "jpeg files (*.jpg)", "*.jpg")
    strFilter = ahtAddFilterItem(strFilter, "gif files (*.gif)", "*.gif")

    Author Comment

    excellent mr.natchiket..
    just one more question.. let's say that i wanted have a path already set in another text box,
    and i can get that value from the text box.., and then add it onto the lookup feature for the .jpg or .gif file,
    how would i add that value of the text box.,.
    let's say that the text box was set to    "c:\pictures"


    Author Comment

    oh,, never mind.. i figured it out..

    thanks guys !!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

    759 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

    9 Experts available now in Live!

    Get 1:1 Help Now