mike60smart
Registered User.
- Local time
- Today, 00:34
- Joined
- Aug 6, 2017
- Messages
- 1,988
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:-
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