[AccessD] Retrieve path to a file

Stuart McLachlan stuart at lexacorp.com.pg
Mon Apr 28 16:49:55 CDT 2003


You also need to set it up with the following Typoe and Declare (I 
usually keep this in a separarte module so that I can do the browse 
from any form:

      Type OPENFILENAME
         lStructSize As Long
         hwndOwner As Long
         hInstance As Long
         lpstrFilter As String
         lpstrCustomFilter As String
         nMaxCustFilter As Long
         nFilterIndex As Long
         lpstrFile As String
         nMaxFile As Long
         lpstrFileTitle As String
         nMaxFileTitle As Long
         lpstrInitialDir As String
         lpstrTitle As String
         flags As Long
         nFileOffset As Integer
         nFileExtension As Integer
         lpstrDefExt As String
         lCustData As Long
         lpfnHook As Long
         lpTemplateName As String
       End Type

Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
         "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long

On 28 Apr 2003 at 12:11, Kathryn Bassett wrote:

> Stuart McLachlan [stuart at lexacorp.com.pg] just did that very thing for
> me. I'm not sure if this is *all* you need, but this is the event
> procedure code for the buttom I click. Background - I have people, and
> a field for the paths of existing pictures. Clicking the "get picutre"
> button opens the windows explorer where I can navigate to the picture,
> select it, and "ta-da" the pathname is now in that field. Note that
> originally, the line that has "D:\MyFiles\Online\muir63\photos63\" was
> instead: OpenFile.lpstrInitialDir = Left$(CurrentDb.Name,
> InStrRev(CurrentDb.Name, "\"))
> 
> Private Sub btnbrowse_Click()
> 
>          Dim OpenFile As OPENFILENAME
>          Dim lReturn As Long
>          Dim sFilter As String
>          OpenFile.lStructSize = Len(OpenFile)
>          OpenFile.hwndOwner = Me.hWnd
>          OpenFile.hInstance = 0
>          sFilter = "" & Chr(0)
>          OpenFile.lpstrFilter = sFilter
>          OpenFile.nFilterIndex = 1
>          OpenFile.lpstrFile = String(257, 0)
>          OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
>          OpenFile.lpstrFileTitle = OpenFile.lpstrFile
>          OpenFile.nMaxFileTitle = OpenFile.nMaxFile
>          ' Start looking in the same directory as the database
>          OpenFile.lpstrInitialDir =
>          "D:\MyFiles\Online\muir63\photos63\" ' Set the caption on the
>          dialog OpenFile.lpstrTitle = "Select Photo" OpenFile.flags =
>          0 lReturn = GetOpenFileName(OpenFile) txtPhoto =
>          Left$(OpenFile.lpstrFile, InStr(OpenFile.lpstrFile, Chr$(0))
>          - 1)
> 
> I don't understand *all* the code he wrote, but I see what is
> happening. Glad to pass along the tip, and hope it helps.
> 

-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System 
Support.





More information about the AccessD mailing list