HillTJ
To train a dog, first know more than the dog..
- Local time
- Today, 06:19
- Joined
- Apr 1, 2019
- Messages
- 731
Hi,
I'm attempting to modify some code so that I can drag a file to a save location but then view the record in it's new location as a hyperlink.
I have a form with a bound field for both "HyperlinkIN" & "HyperlinkOUT"
I think the problem is that the string returned does not include the username? Then crashes at the "Filecopy" line. If I recall it worked OK when I first tried it on a networked PC.
Any clues?. Have I given sufficient to work on?
As always, appreciate any help.
Private Sub HyperlinkIN_AfterUpdate()
Dim InPath As String
Dim FileName As String
Dim OutFolder As String
Dim OutPath As String
Dim RecordNo As String
Dim FileExt As String
Dim objFSO As Object
Dim strHyperlinkPath As String
Set objFSO = CreateObject("Scripting.FileSystemObject")
InPath = objFSO.GetAbsolutePathName(Me.HyperlinkIN.Hyperlink.Address)
OutFolder = objFSO.GetAbsolutePathName(Me.HyperlinkOUT.Hyperlink.Address)
'OutFolder = Me.HyperlinkOUT & ""
Debug.Print Me.HyperlinkOUT
RecordNo = Me!ID
If Len(InPath) > 0 Then
FileName = Right(InPath, Len(InPath) - InStrRev(InPath, "")) 'get the file name
FileExt = Right(FileName, Len(FileName) - InStrRev(FileName, ".") + 1) ' get the file extension with dot
'build the new path with output folder path and record number and date and extension
OutPath = OutFolder & "" & "Record" & RecordNo & " Attachment " & Format(Now(), "ddmmmyy") & FileExt
If (IsNull(Me.[Out_Path]) Or Me.[Out_Path] = "") Then Me.[Out_Path] = OutPath 'Allows the file save position to be relocated"
Debug.Print InPath
Debug.Print Out_Path
FileCopy InPath, Out_Path
Me!HyperlinkOUT = "#" & [Out_Path] & "#"
MsgBox "Copied file to archives " & vbCrLf & InPath & vbCrLf & OutPath
End If
End Sub
I'm attempting to modify some code so that I can drag a file to a save location but then view the record in it's new location as a hyperlink.
I have a form with a bound field for both "HyperlinkIN" & "HyperlinkOUT"
I think the problem is that the string returned does not include the username? Then crashes at the "Filecopy" line. If I recall it worked OK when I first tried it on a networked PC.
Any clues?. Have I given sufficient to work on?
As always, appreciate any help.
Private Sub HyperlinkIN_AfterUpdate()
Dim InPath As String
Dim FileName As String
Dim OutFolder As String
Dim OutPath As String
Dim RecordNo As String
Dim FileExt As String
Dim objFSO As Object
Dim strHyperlinkPath As String
Set objFSO = CreateObject("Scripting.FileSystemObject")
InPath = objFSO.GetAbsolutePathName(Me.HyperlinkIN.Hyperlink.Address)
OutFolder = objFSO.GetAbsolutePathName(Me.HyperlinkOUT.Hyperlink.Address)
'OutFolder = Me.HyperlinkOUT & ""
Debug.Print Me.HyperlinkOUT
RecordNo = Me!ID
If Len(InPath) > 0 Then
FileName = Right(InPath, Len(InPath) - InStrRev(InPath, "")) 'get the file name
FileExt = Right(FileName, Len(FileName) - InStrRev(FileName, ".") + 1) ' get the file extension with dot
'build the new path with output folder path and record number and date and extension
OutPath = OutFolder & "" & "Record" & RecordNo & " Attachment " & Format(Now(), "ddmmmyy") & FileExt
If (IsNull(Me.[Out_Path]) Or Me.[Out_Path] = "") Then Me.[Out_Path] = OutPath 'Allows the file save position to be relocated"
Debug.Print InPath
Debug.Print Out_Path
FileCopy InPath, Out_Path
Me!HyperlinkOUT = "#" & [Out_Path] & "#"
MsgBox "Copied file to archives " & vbCrLf & InPath & vbCrLf & OutPath
End If
End Sub