Link a button to a folder

Rob U Blind

New member
Local time
Today, 06:02
Joined
Jul 31, 2009
Messages
1
Hi sorry if this has been covered in previous posts, I am using a basic form with a couple of buttons linking to tables etc, but I would like to add one that links not to a specific word/excel file but the folder in which they are stored,

Basically the form I am using list job details for specific contracts and I would like to link each page with its original quote, or at least give the user the ability to open the "quotes folder" in order to look at the numerous quotes that relate to the Job detailed on the form.
A conveluted explanation I know but I can't see the options I need in the "wizard" and my knowledge of VBA ends at the letter "A"!!!!!!
Hope you can help

Kind Regards
 
the noertwind sample "specially 2003" will help you very much..
go to the employees form.. open the code and see how you can add/change the photo by browsing the folder,, you can alter the code in the module to handle the files type you want,,,
me,,, i use chooseFile() i used it for storing the Scans of maps of buildings and lands for sales in a contractors's database...
Code:
Option Compare Database
Option Explicit
Public 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
Public Declare Function GetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public Function Choose_File(Optional SpecialFolder As String) As String
 
 Dim ofn As OPENFILENAME
 Dim DirFile As String
 Dim AfrmName As String
 Dim myUser As String
 Dim i As Long
 Dim NeedUpdating As Boolean
 
 ofn.lStructSize = Len(ofn)
 ofn.lpstrFilter = "Bmp (*.Bmp)" + Chr$(0) + "*.Bmp" + Chr$(0)
 ofn.lpstrFile = space$(254)
 ofn.nMaxFile = 255
 ofn.lpstrFileTitle = space$(254)
 ofn.nMaxFileTitle = 255
 ofn.lpstrInitialDir = SpecialFolder
 ofn.lpstrTitle = "ãÓÇÑ ÇáãáÝ"
 ofn.flags = 0
        
 Dim A
 A = GetOpenFileName(ofn)
        
 If (A) = False Then Exit Function
        
 Choose_File = Trim$(ofn.lpstrFile)
 Do
    If Asc(Right(Choose_File, 1)) < 33 Then
       Choose_File = Left(Choose_File, Len(Choose_File) - 1)
    Else
       Exit Do
    End If
 Loop
End Function
Public Function FolderPath(ByVal InFilePath As String) As String
If InFilePath = "" Then Exit Function
Dim strDBFile As String
strDBFile = Dir(InFilePath)
If strDBFile = "" Then Exit Function
FolderPath = Left(InFilePath, InStr(InFilePath, strDBFile) - 1)
End Function

THE CALLING:UNDER A CLICK BUTTON OR ANY OTHER TRIGGER
Code:
Dim A
A = Choose_File(FolderPath(Nz(Me.MapPath, "")))
If Nz(A, "") <> "" Then
  Me.MapPath = A
  Me.Image36.Picture = A
End If
 

Users who are viewing this thread

Back
Top Bottom