Selecting information

Dannyc989

Registered User.
Local time
Today, 12:22
Joined
Dec 18, 2013
Messages
46
I have some code where by I want to move a folder from one location to another but the strings/paths are both on the form...

I have sfoldersource = me.quote_files_directory_ref

But it keeps throwing back an Error... Where am I going wrong??
 
Sorry ISP decided they didnt want to fix my fault before the weekend had no internet...

please see below the entire code I have on the page, the part im having problems with is the coping of the entire folder and it returns a Path not found and the debug points me towards the bold red line

Private Sub Form_Open(Cancel As Integer)
DoCmd.RunCommand acCmdRecordsGoToLast

Dim LFolderpath As String
Dim LResponse As String
On Error GoTo NFolder
LFolderpath = "C:\Users\Daniel\Desktop\NT Projects\" & [Project Number] & "_" & [Client] & "_" & [Description]
If Len(Dir("LFolderpath", vbDirectory)) = 0 Then
Application.FollowHyperlink LFolderpath
End If
NFolder:
LResponse = MsgBox("Folder doesn't exist for" & " " & [Project Number] & "_" & [Client] & "_" & [Description] & "." & " " & "Would you like to create a new folder?", vbYesNo)
If LResponse = "6" Then
MkDir LFolderpath
Application.FollowHyperlink LFolderpath
Else
MsgBox ("No folder created and no folder exists")
End If
Me.Files_Directory = "C:\Users\Daniel\Desktop\NTProjects\" & [Project Number] & "_" & [Client] & "_" & [Description]

On Error GoTo Error_Handler
Dim fs As Object

sFolderSource = Me.Quote_File_Directory_Ref

sFolderDestination = "C:\Users\Daniel\Desktop\NTProjects\" & [Project Number] & "_" & [Client] & "_" & [Description]


Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFolder sFolderSource, sFolderDestination, bOverWriteFiles
fs.DeleteFolder sFolderSource, True

Eror_Handler_Exit:
On Error Resume Next
Set fs = Nothing


Error_Handler:
If Err.Number = 76 Then
MsgBox "The 'Source Folder' could not be found to make a copy of.", _
vbCritical, "Unable to Find the Specified Folder"
Else
MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: MoveFolder" & vbCrLf & _
"Error Description: " & Err.Description, _
vbCritical, "An Error has Occured!"
End If

Dim OutlookApp As Object
Dim MailIt As Object
Dim EmailAddr As String

Set OutlookApp = CreateObject("Outlook.Application")

'Email Addresses

EmailAddr = "d.collins@ntsecurity.com" & ";" & "i.bernard@ntsecurity.com" & ";" & "a.purvis@ntsecurity.co.uk"
'Create Mail Item
Set MailIt = OutlookApp.CreateItem(0)
With MailIt
.To = EmailAddr
.Subject = "New Project"
.Body = Me.Project_Number & ", " & Me.Client & ", " & Me.Site_Reference & ", " & Me.Description
.Display
End With

DoCmd.Close acForm, "Project Numbers1"

End Sub
 

Users who are viewing this thread

Back
Top Bottom