I have a form where I link files which are saved to a Path: H:\2019 Ledger\Office Attachments 2019\Gujranwala\GUJ Purchase
Before I splited the DB it was working perfectly. Now after the split no files can be saved or linked.
Can someone help me with this.
Private Sub AttachmentA_Click()
Dim fDialog As Object
Dim oldFileName As String, OldFilePath As String
Dim NewFileName As String, NewFilePath As String
Dim varFile As Variant
If IsNull(AttachmentA) Or AttachmentA.Text = "" Then
NewFilePath = "H:\2019 Ledger\Office Attachments 2019\Gujranwala\GUJ Purchase"
' Set up the File Dialog. '
Set fDialog = Application.FileDialog(3)
With fDialog
' Set the title of the dialog box. '
.Title = "Please select the image to attach"
' Clear out the current filters, and add our own.'
.Filters.Clear
.Filters.Add "All Files", "*.*"
.AllowMultiSelect = False
If .Show = -1 Then
oldFileName = .SelectedItems(1)
NewFileName = NewFilePath & Format(PurTransId.Value, "0000") & " " & "CoID-" & PurCoId.Value & " " & [EntryPLogin By].Value & " GUJPur-Att1." & Right(oldFileName, 4)
FileCopy oldFileName, NewFileName
AttachmentA = NewFileName
Else
MsgBox "File selection cancelled!"
Exit Sub '<< code may attempt to follow hyperlink when no file was selected. Then again, maybe not but I would Exit to be sure
End If
End With
Else
If Dir(AttachmentA.Text) <> "" And AttachmentA.Text <> "" Then
Application.FollowHyperlink AttachmentA
Else
MsgBox ("Attachment Deleted & Does Not Exist In Attachment Folder" & vbNewLine & "Check Attachment Or Remove This Invalid Path." & vbNewLine & vbNewLine & "To Remove HIGHLIGHT The PATH & Use BACKSPACE Button."), vbExclamation
End If
End If
End Sub
Private Sub AttachmentA_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 46 Then
result = MsgBox("Do you wish to delete the file?", vbYesNo)
If result = vbYes And Dir(AttachmentA.Text) <> "" Then
Kill (AttachmentA.Text)
Else
MsgBox ("Operation Cancelled"), vbInformation
KeyCode = 0
End If
End If
End Sub