Kathryn Bassett
kathryn at bassett.net
Mon Apr 28 14:11:36 CDT 2003
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. -- Kathryn Bassett (Pasadena CA) http://www.databaseadvisors.com http://databaseadvisors.com/mailman/listinfo kathryn at bassett.net * http://bassett.net > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Joe Rojas > Sent: 28 Apr 2003 10:47:AM > To: 'accessd at databaseadvisors.com' > Subject: [AccessD] Retrieve path to a file > > > Hello All, > > How does anyone have any code examples that results in a dialog box opening > and allows that user to navigate to a specified file and return the path to > the file? > I am pretty sure that it is possible to use windows API calls for something > like this, but I am not very knowledgeable about using API calls. > > Thanks! > > Joe Rojas >