File Picker (1 Viewer)

mike60smart

Registered User.
Local time
Today, 00:23
Joined
Aug 6, 2017
Messages
1,980
Hi
I am trying to use the following Code to Pick a File Path.
Any help appreciated.

When I run the Code I get the following error:-

The code is as follows:-

Code:
'***************************************************************************************
' Module    : Form_f_Artwork_Server
' Author    : CARDA Consultants Inc.
' Website   : http://www.cardaconsultants.com
' Copyright : Please note that U.O.S. all the content herein considered to be
'             intellectual property (copyrighted material).
'             It may not be copied, reused or modified in any way without prior
'             authorization from its author(s).
'***************************************************************************************


Option Compare Database
Option Explicit


Private Const sModName = "Form_f_Method2_Server"




'Close the form
Private Sub cmd_FrmClose_Click()
    On Error GoTo Error_Handler


    DoCmd.Close acForm, Me.Name, acSaveNo


Error_Handler_Exit:
    On Error Resume Next
    Exit Sub


Error_Handler:
    MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
           "Error Number: " & Err.Number & vbCrLf & _
           "Error Source: " & sModName & "\cmd_FrmClose_Click" & vbCrLf & _
           "Error Description: " & Err.Description & _
           Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
           , vbOKOnly + vbCritical, "An Error has Occured!"
    Resume Error_Handler_Exit
End Sub


'Add a new attachment to the database and copy the file to the server
Private Sub cmd_LocateFile_Click()
    On Error GoTo Error_Handler
    Dim sFile                 As String
    Dim sFolder               As String


    sFile = FSBrowse("", msoFileDialogFilePicker, "All Files (*.*),*.*")
    If sFile <> "" Then
        sFolder = Application.CodeProject.Path & "\" & sAttachmentFolderName & "\"
        'Ensure the Attachment folder exists
        If FolderExist(sFolder) = False Then MkDir (sFolder)
        'Copy the file to the Attachment folder
        If CopyFile(sFile, sFolder & GetFileName(sFile)) = True Then
            'Add this new path to our db
            Me.FullFileName = sFolder & GetFileName(sFile)
        Else
            'Probably should report something here about the File Copy failing
        End If
    End If


Error_Handler_Exit:
    On Error Resume Next
    Exit Sub


Error_Handler:
    MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
           "Error Number: " & Err.Number & vbCrLf & _
           "Error Source: " & sModName & "\cmd_LocateFile_Click" & vbCrLf & _
           "Error Description: " & Err.Description & _
           Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
           , vbOKOnly + vbCritical, "An Error has Occured!"
    Resume Error_Handler_Exit
End Sub


'Delete the current attachment/record and the attachment file itself
Private Sub cmd_RecDel_Click()
    On Error GoTo Error_Handler
    Dim sFile                 As String
    
    sFile = Me.FullFileName
    'Delete the database record
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    'If we're here the record was deleted, so let delete the actual file from the server
    Kill sFile


Error_Handler_Exit:
    On Error Resume Next
    Exit Sub


Error_Handler:
    If Err.Number <> 2501 Then
        MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
               "Error Number: " & Err.Number & vbCrLf & _
               "Error Source: " & sModName & "\cmd_RecDel_Click" & vbCrLf & _
               "Error Description: " & Err.Description & _
               Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
               , vbOKOnly + vbCritical, "An Error has Occured!"
    End If
    Resume Error_Handler_Exit
End Sub


'Open the attachment
Private Sub cmd_ViewFile_Click()
    On Error GoTo Error_Handler


    Call ExecuteFile(Me.FullFileName, "Open")


Error_Handler_Exit:
    On Error Resume Next
    Exit Sub


Error_Handler:
    MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
           "Error Number: " & Err.Number & vbCrLf & _
           "Error Source: " & sModName & "\cmd_ViewFile_Click" & vbCrLf & _
           "Error Description: " & Err.Description & _
           Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
           , vbOKOnly + vbCritical, "An Error has Occured!"
    Resume Error_Handler_Exit
End Sub
 

Attachments

  • error.JPG
    error.JPG
    83.4 KB · Views: 385
Mike, it seems you may have a duplicate procedure name (FSBrowse) on your system.
You could check.

I know I have one that I use from time to time.

'---------------------------------------------------------------------------------------
' Procedure : FSBrowse
' Author : mellon 'from Adrian Bell/neopa Bytes
' Date : 21-Jun-2017
' Purpose :
'FSBrowse (File System Browse) allows the operator to browse for a file/folder. [neopa/adrian Bell-bytes]
' strStart specifies where the process should start the browser.
' lngType specifies the MsoFileDialogType to use.
' strPattern specifies which FileType(s) should be included.
'---------------------------------------------------------------------------------------
 
It could also be that you have a module with that name.
 
Mike, it seems you may have a duplicate procedure name (FSBrowse) on your system.
You could check.

I know I have one that I use from time to time.

'---------------------------------------------------------------------------------------
' Procedure : FSBrowse
' Author : mellon 'from Adrian Bell/neopa Bytes
' Date : 21-Jun-2017
' Purpose :
'FSBrowse (File System Browse) allows the operator to browse for a file/folder. [neopa/adrian Bell-bytes]
' strStart specifies where the process should start the browser.
' lngType specifies the MsoFileDialogType to use.
' strPattern specifies which FileType(s) should be included.
'---------------------------------------------------------------------------------------
Hi Jdraw Well how I did that I don't know. Both Modules associated with the process had been Imported again. Hence the duplicate.

Many thanks
 
Where are recordsets mentioned? :unsure:
 
Hi Gasman
??? have you posted in the wrong thread?
No, there was a post from a user with some code, mentioning no need for recordsets when outputting reports? I think there was a Lee in the username somewhere? Now that post has disappeared. :(
 
The poster deleted that post a couple of minutes after posting it.
 
The poster deleted that post a couple of minutes after posting it.
Well they need to be quicker than that, as I read the thread several times, looking for recordsets, before I posted. :)
 

Users who are viewing this thread

Back
Top Bottom