Hi im getting an error on a line from my export code, but I cant figure out whats wrong. The line in red is wheer the debug points to.
Code:
Private Sub btnExportTrainingRecord_Click()
Dim strday As String 'The date
Dim sDest As String 'Where the file will be copied to
Dim sSource As String 'The name of the file to be copied
Dim strBackUpDir As String
Dim strBackUpFolder As String
Dim strBackUpDogNameFolder As String
Dim strDogName As String 'The name of the dog that is geting exported
strBackUpDir = "c:\GPandDetectionDogTrainingLogBackUp\"
strBackUpFolder = "c:\GPandDetectionDogTrainingLogBackUp\Training"
strBackUpDogNameFolder = "c:\GPandDetectionDogTrainingLogBackUp\Training\" & Forms![frm_Profile]![DogName]
If Len(Dir(strBackUpDir, vbDirectory)) = 0 Then
MkDir strBackUpDir
End If
If Len(Dir(strBackUpFolder, vbDirectory)) = 0 Then
MkDir strBackUpFolder
End If
If Len(Dir(strBackUpDogNameFolder, vbDirectory)) = 0 Then
MkDir strBackUpDogNameFolder
End If
Shell "EXPLORER.EXE " & strBackUpDogNameFolder, vbNormalFocus
strday = Format(Now(), "_yyyy_mm_dd")
[COLOR="Red"]sSource = "c:\GPandDetectionDogTrainingLogBackUp\Training\GPandDetectionDogTrainingLogBackUpTraining\" & strBackUpDogNameFolder \ "GPandDetectionDogTrainingLogBackUpTraining"[/COLOR]
strDogName = Forms![frm_Profile]![DogName]
sDest = "c:\GPandDetectionDogTrainingLogBackUp\Training\GPandDetectionDogTrainingLogBackUpTraining\" & strBackUpDogNameFolder \ "GPandDetectionDogTrainingLogBackUpTraining" & strDogName & strday & ".xls"
'Copies the files to Excel
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry_DetectionTraining", "c:\GPandDetectionDogTrainingLogBackUp\Training\" & strBackUpDogNameFolder \ "GPandDetectionDogTrainingLogBackUpTraining.xls", True
'Copies and renames the file
FileCopy sSource, sDest
End Sub