[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

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

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].SetFocus
           
            Me![ImagePath].Text = fileName
         
            Me![Photo1].Value = -1
            Form_InspectionMain.SetFocus
            Form_InspectionMain.Address1.SetFocus
            Form_FoundationCrawlSpace.ImageFrame.Visible = True
            Form_InspectionMain.Address1.SetFocus
            Form_FoundationCrawlSpace.Inspected.SetFocus
            Form_FoundationCrawlSpace.ImagePath.Visible = False
     
        End If
   
    End With
       

End Sub
0
kevinsrea
Asked:
kevinsrea
  • 4
  • 3
2 Solutions
 
mbizupCommented:
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:

http://www.mvps.org/access/api/api0001.htm
0
 
mbizupCommented:
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...", _
                Flags:=ahtOFN_HIDEREADONLY)



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

kevin
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
mbizupCommented:
Give the API code at the URL I posted a try.  That should work for you.
0
 
kevinsreaAuthor Commented:
ok,, it seems to be working.., how do i modify the code so it just looks for the filetype   .jpg and   .gif ?

thanks,

Kevin

0
 
NatchiketCommented:
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")
0
 
kevinsreaAuthor Commented:
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"

thanks,
kevin
0
 
kevinsreaAuthor Commented:
oh,, never mind.. i figured it out..

thanks guys !!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now