Hi and Good Day to all,
Before I start, I would like to inform to you guys that I am very very new to Microsoft Access. So, my question might be pretty easy to all.
I am working on Access project where there is a form where user will enter data into in. After complete for data entry, they will click Browse button to select file that they want to rename and to move. After they click Save button, the form will save all the data that the users had enters and it will rename and move the file location to a new location.
So, the problem is, there is an error showed saying "Error 53:File not found."
and it showed to this line of code Name Me.DisplayFileName As FileToSaveLocation. I am pretty sure sure that the file is on the location. I do not know what the problem is. Can anyone please help me with this? :/
this is my code for Browse:
Dim f As Object
Dim strFile As String
Dim strFolder As String
Dim varItem As Variant
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
If f.Show Then
For Each varItem In f.SelectedItems
strFile = Dir(varItem)
strFolder = Left(varItem, Len(varItem) - Len(strFile))
MsgBox "Folder: " & strFolder & vbCrLf & _
"File: " & strFile
Me.DisplayFileName = strFolder & strFile
Next
End If
Set f = Nothing
End If
and this is the code for rename and move file
Dim FileToSaveLocation As String
If IsNull(DisplayFileName) Then
MsgBox "Please select file to save!", vbCritical 'check da plih file ke belum
Else
FileToSaveLocation = "C:\Users\User\Desktop\project\ET Report" & "\" & ReportNumber.Value & ".pdf"
Name Me.DisplayFileName As FileToSaveLocation
End If
Before I start, I would like to inform to you guys that I am very very new to Microsoft Access. So, my question might be pretty easy to all.
I am working on Access project where there is a form where user will enter data into in. After complete for data entry, they will click Browse button to select file that they want to rename and to move. After they click Save button, the form will save all the data that the users had enters and it will rename and move the file location to a new location.
So, the problem is, there is an error showed saying "Error 53:File not found."
and it showed to this line of code Name Me.DisplayFileName As FileToSaveLocation. I am pretty sure sure that the file is on the location. I do not know what the problem is. Can anyone please help me with this? :/
this is my code for Browse:
Dim f As Object
Dim strFile As String
Dim strFolder As String
Dim varItem As Variant
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
If f.Show Then
For Each varItem In f.SelectedItems
strFile = Dir(varItem)
strFolder = Left(varItem, Len(varItem) - Len(strFile))
MsgBox "Folder: " & strFolder & vbCrLf & _
"File: " & strFile
Me.DisplayFileName = strFolder & strFile
Next
End If
Set f = Nothing
End If
and this is the code for rename and move file
Dim FileToSaveLocation As String
If IsNull(DisplayFileName) Then
MsgBox "Please select file to save!", vbCritical 'check da plih file ke belum
Else
FileToSaveLocation = "C:\Users\User\Desktop\project\ET Report" & "\" & ReportNumber.Value & ".pdf"
Name Me.DisplayFileName As FileToSaveLocation
End If