Hey Guys, I have another issue. I'm trying to save the filepath to the table and I'm getting the error below. I thought it would be the same as for saving the filename. I don't understand why the field has to be mentioned twice, eg """ & Filename & """,""" & Filename & """
Thank you in advance>
Thank you in advance>
Code:
Set FD = Application.FileDialog(msoFileDialogFilePicker)
With FD
.InitialFileName = DogFolder
.AllowMultiSelect = IIf(DocType = "BulkAdd", True, False)
.Title = "Select a File"
.Filters.Clear
If DocType = "Entity" Then
.Filters.Add "JPG Files", "*.jpg"
.Filters.Add "GIF Files", "*.gif"
.Filters.Add "PNG Files", "*.png"
Else
.Filters.Add "All Files", "*.*"
End If
If .Show = True Then
For Each PickFile In .SelectedItems
FilePath = PickFile
Filename = FileNameFromPath(FilePath)
If DocType = "Entity" Then
Forms!frmDogProfile!MyPicture = Filename
NewFilePath = DogIDFolder & "\" & Filename
ElseIf DocType = "Document" Then
Forms!frmDocument!Filename = Filename
Forms!frmDocument!Description = Filename
NewFilePath = DocumentFolder & "\" & Filename
'Forms!frmDocument.RefreshDocImage
Else ' Bulk Add
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblDocument (DogID, Filename, FilePath, Description) " & _
"VALUES (" & DogID & ", """ & Filename & """,""" & Filename & """, """ & NewFilePath & """,""" & NewFilePath & """)"
DoCmd.SetWarnings True
NewFilePath = DocumentFolder & "\" & Filename
End If
FileCopy FilePath, NewFilePath
If Not FileExists(NewFilePath) Then
MsgBox "ERROR: File Copy Failed. " & NewFilePath
Exit Sub
End If
Next
End If
End With