OpenFile Help

bonekrusher

Registered User.
Local time
Today, 15:10
Joined
Nov 19, 2005
Messages
266
Hi Everyone,

I have a code to open a file. The Code gets the file name from a field called "tbFile". The users that need to access this file and open it are on a server and have mapped their drives with different letters. So I want the Code to be used from anyones computer.

How do I incorperate the "Path = Me.Application.CurrentProject.Path" function to retrieve the file?

Code:
Private Sub bOpenFile_Click()
On Error GoTo Err_bOpen_Click

    Me.tbHidden.SetFocus

    If IsNull(tbFile) Or tbFile = "" Then
        MsgBox "Please browse and select a valid file to open.", vbCritical, "Invalid File"
    Else
        OpenFile (tbFile)
    End If

Exit_bOpen_Click:
    Exit Sub

Err_bOpen_Click:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_bOpen_Click

End Sub
 
Answer!

In case anyone was interested, here is the solution:

Code:
Private Sub bOpenFile_Click()
On Error GoTo Err_bOpen_Click
Dim PT As String

    Me.tbHidden.SetFocus

    If IsNull(tbFile) Or tbFile = "" Then
        MsgBox "Please browse and select a valid file to open.", vbCritical, "Invalid File"
    Else
        PT = CurrentProject.Path & Me.tbFile
        OpenFile (PT)
        
    End If

Exit_bOpen_Click:
    Exit Sub

Err_bOpen_Click:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_bOpen_Click

End Sub
 
Excellent! I am glad to see that you were able to search and resolve your own problem. I also recognize your code. ;) Good luck with your project!
 
Thanks ghudson, I think I am getting the hang of VB. This is a great site and with out it I couldn't have built my database. Thanks to you and everyone thats been helpful!

Bones
 

Users who are viewing this thread

Back
Top Bottom