Error 75 Path/File Access error

P

p

We have a upsized access 2000 (ODBC front SQL Back) that we permit users to
"Attach" files to the app. Attach button allows users to pick a file (xls,
doc, pdf, csv) on their compuer, which gets copied to a server share,
verifies file exists in share, then UNC Path gets set for each attachment.
We run this on Citrix for 20 offices and 100 users around country but some
remote (geographically) users have problems attaching files Err 75 etc. I
added a delay of 100ms in error handler which can get called 5 times. When
they send me a file I can always attach this locally. Any ideas how to
handling the errors better or processing file copy/retries better? P

' UNC file root
strDestFile = "\\Server1\Pipeline\ServPickingTicket"
' 1)counter to count retries in case of err during filecopy.
Dim ErrOpenCntr As Integer
Dim ErrCounter As Integer
ErrOpenCntr = 0
ErrCounter = 0
On Error GoTo ErrorHandler
' check for Purchasing Material code Explosion file
If Not IsNull([SysFileAttachServPickTicketUNC]) Then
' File is Missing but path was found
' Check for valid path 5 more times, then fail
Do While isPathOk([SysFileAttachServPickTicketUNC]) = False
' count retrys
ErrOpenCntr = ErrOpenCntr + 1
' if file open retried 5 times then quit.
If ErrOpenCntr >= 5 Then
MsgBox "The file " & [SysFileAttachServPickTicketUNC] & "
can not be opened right now but please retry again."
Exit Sub
End If
' pause 100ms
Sleep 100
Loop
' Open file if found on a retry.
Call fHandleFile([SysFileAttachServPickTicketUNC], WIN_NORMAL)
Else ' File is not there open one and store
' Call getPath with standard windows file open
' Make list of file filters
' FilterName & Null & FileFilter & Null
' String needs to end with 2 nulls
' added excel, word, text and all files
strFilter = "Excel Files (*.xls,*.csv)" & vbNullChar &
"*.xl?;*.csv" & vbNullChar
strFilter = strFilter & "Word Files (*.doc)" & vbNullChar & "*.doc"
& vbNullChar
strFilter = strFilter & "Adobe Acrobat Files (*.pdf)" & vbNullChar
& "*.pdf" & vbNullChar
strFilter = strFilter & "Text Documents (*.txt)" & vbNullChar &
"*.txt" & vbNullChar
strFilter = strFilter & "All Files (*.*)" & vbNullChar & "*.*" &
String(2, vbNullChar)

strSrcFile = getFile(, strFilter, , "Choose File Above")
For i = 1 To Len(strSrcFile)
If Asc(Mid(strSrcFile, i, 1)) <> 0 Then
strTempName = strTempName + Mid(strSrcFile, i, 1)
End If
Next i
strSrcFile = strTempName
' if cancel was pressed exit sub
If Len(strSrcFile) < 1 Then
Exit Sub
End If

' Check Quote# and make sure not empty string
If Not IsNull(Me.Reference_.Value) Then
strQuote = Trim(Me.Reference_)
Else
MsgBox "This record must have a quote number first!"
Exit Sub
End If

' get file extension including dot
strFileExt = Right(strSrcFile, Len(strSrcFile) -
InStrRev(strSrcFile, ".", , vbTextCompare) + 1)
Trim (strFileExt)
' append together full dest file name
strDestFile = strDestFile + strQuote + strFileExt
'MsgBox "DestFile = " & strDestFile

' FileCopy "strsrc", "strdest"
FileCopy strSrcFile, strDestFile
' Verify file copied then update db with path and change button
If isPathOk(strDestFile) = True Then
' set value in Tracklog
[SysFileAttachServPickTicketUNC] = strDestFile

' Change button caption
cmdServPickTic.Caption = "View File"
cmdServPickTic.FontBold = True
cmdServPickTic.ForeColor = vbRed
Else
' warn user file did not Copy
MsgBox "The file=" & strDestFile & " did NOT copy successfully.
Please retry."
End If
End If

' 3) exit when success add after last end if and end sub
Exit Sub

ErrorHandler:
' increment and retry 5 times
ErrCounter = ErrCounter + 1
If ErrCounter <= 5 Then
' pause 100ms
Sleep 100
' retry err provoking statement
Resume
Else
' reset counter
ErrCounter = 0
' After 5 times
MsgBox "There was a problem attaching this file, Please try again at
a different time. Error = " & Err.Number & " Description=" &
AccessError(Err.Number)
' exit sub because of err
Exit Sub
End If
End Sub
 
R

Ron Weiner

In a previous life I had to allow Citrix users to upload files to a server
share from access. In the two years that this app was in production I don't
think I ever got more than a handful of calls from users that had trouble.
In every case the cause of the trouble was that the user did not enter the
source name of the file accurately, and the app would throw a Path/File
Access error. What you can do to isolate this is to attempt a Dir() on the
user's source file before the copy operation. Something like:

If Len(Dir("\\Client\" & FullClientSourceFilespec)) > 0 Then
' Attempt to Copy the file as the Source File Exists
FileCopy ("\\Client\" & FullClientSourceFilespec, "\\yourUNCShare" &
FilenamePartOfFullClientSourceFilespec
'... and all of the other stuff you have to do
Else
MsgBox "Error: Source filename does not exist!", vbExclamation, "
Bad Filename"
End If

Something like this will give you at least a fighting chance. A hundred
retries to copy a non existent file will result in 100 failures to copy the
file.

Ron W
p said:
We have a upsized access 2000 (ODBC front SQL Back) that we permit users to
"Attach" files to the app. Attach button allows users to pick a file (xls,
doc, pdf, csv) on their compuer, which gets copied to a server share,
verifies file exists in share, then UNC Path gets set for each attachment.
We run this on Citrix for 20 offices and 100 users around country but some
remote (geographically) users have problems attaching files Err 75 etc. I
added a delay of 100ms in error handler which can get called 5 times. When
they send me a file I can always attach this locally. Any ideas how to
handling the errors better or processing file copy/retries better? P

' UNC file root
strDestFile = "\\Server1\Pipeline\ServPickingTicket"
' 1)counter to count retries in case of err during filecopy.
Dim ErrOpenCntr As Integer
Dim ErrCounter As Integer
ErrOpenCntr = 0
ErrCounter = 0
On Error GoTo ErrorHandler
' check for Purchasing Material code Explosion file
If Not IsNull([SysFileAttachServPickTicketUNC]) Then
' File is Missing but path was found
' Check for valid path 5 more times, then fail
Do While isPathOk([SysFileAttachServPickTicketUNC]) = False
' count retrys
ErrOpenCntr = ErrOpenCntr + 1
' if file open retried 5 times then quit.
If ErrOpenCntr >= 5 Then
MsgBox "The file " & [SysFileAttachServPickTicketUNC] & "
can not be opened right now but please retry again."
Exit Sub
End If
' pause 100ms
Sleep 100
Loop
' Open file if found on a retry.
Call fHandleFile([SysFileAttachServPickTicketUNC], WIN_NORMAL)
Else ' File is not there open one and store
' Call getPath with standard windows file open
' Make list of file filters
' FilterName & Null & FileFilter & Null
' String needs to end with 2 nulls
' added excel, word, text and all files
strFilter = "Excel Files (*.xls,*.csv)" & vbNullChar &
"*.xl?;*.csv" & vbNullChar
strFilter = strFilter & "Word Files (*.doc)" & vbNullChar & "*.doc"
& vbNullChar
strFilter = strFilter & "Adobe Acrobat Files (*.pdf)" & vbNullChar
& "*.pdf" & vbNullChar
strFilter = strFilter & "Text Documents (*.txt)" & vbNullChar &
"*.txt" & vbNullChar
strFilter = strFilter & "All Files (*.*)" & vbNullChar & "*.*" &
String(2, vbNullChar)

strSrcFile = getFile(, strFilter, , "Choose File Above")
For i = 1 To Len(strSrcFile)
If Asc(Mid(strSrcFile, i, 1)) <> 0 Then
strTempName = strTempName + Mid(strSrcFile, i, 1)
End If
Next i
strSrcFile = strTempName
' if cancel was pressed exit sub
If Len(strSrcFile) < 1 Then
Exit Sub
End If

' Check Quote# and make sure not empty string
If Not IsNull(Me.Reference_.Value) Then
strQuote = Trim(Me.Reference_)
Else
MsgBox "This record must have a quote number first!"
Exit Sub
End If

' get file extension including dot
strFileExt = Right(strSrcFile, Len(strSrcFile) -
InStrRev(strSrcFile, ".", , vbTextCompare) + 1)
Trim (strFileExt)
' append together full dest file name
strDestFile = strDestFile + strQuote + strFileExt
'MsgBox "DestFile = " & strDestFile

' FileCopy "strsrc", "strdest"
FileCopy strSrcFile, strDestFile
' Verify file copied then update db with path and change button
If isPathOk(strDestFile) = True Then
' set value in Tracklog
[SysFileAttachServPickTicketUNC] = strDestFile

' Change button caption
cmdServPickTic.Caption = "View File"
cmdServPickTic.FontBold = True
cmdServPickTic.ForeColor = vbRed
Else
' warn user file did not Copy
MsgBox "The file=" & strDestFile & " did NOT copy successfully.
Please retry."
End If
End If

' 3) exit when success add after last end if and end sub
Exit Sub

ErrorHandler:
' increment and retry 5 times
ErrCounter = ErrCounter + 1
If ErrCounter <= 5 Then
' pause 100ms
Sleep 100
' retry err provoking statement
Resume
Else
' reset counter
ErrCounter = 0
' After 5 times
MsgBox "There was a problem attaching this file, Please try again at
a different time. Error = " & Err.Number & " Description=" &
AccessError(Err.Number)
' exit sub because of err
Exit Sub
End If
End Sub
 
P

p

Ron,

I will try adding this code to check the file just before copying. Thanks
for suggestion.

I have them use a file dialog box to pick the file to copy. 90% have the
files, to attach, stored on their local machine "My Documents". Sometimes
during errors, I have shadowed them, watched them click an "Attach" button,
browse to file on their HD, click "OK" to copy and get that error? I dont
think they are using using laptops so HD powerdown should not occur. The
network does not appear to have problems, am able to ping both ways. The
server share is actually a NAS and wonder if that could affect something.
But it seems the only users who have problems are remote so there is no
common thread there except distance?

Thanks Again
P


Ron Weiner said:
In a previous life I had to allow Citrix users to upload files to a server
share from access. In the two years that this app was in production I don't
think I ever got more than a handful of calls from users that had trouble.
In every case the cause of the trouble was that the user did not enter the
source name of the file accurately, and the app would throw a Path/File
Access error. What you can do to isolate this is to attempt a Dir() on the
user's source file before the copy operation. Something like:

If Len(Dir("\\Client\" & FullClientSourceFilespec)) > 0 Then
' Attempt to Copy the file as the Source File Exists
FileCopy ("\\Client\" & FullClientSourceFilespec, "\\yourUNCShare" &
FilenamePartOfFullClientSourceFilespec
'... and all of the other stuff you have to do
Else
MsgBox "Error: Source filename does not exist!", vbExclamation, "
Bad Filename"
End If

Something like this will give you at least a fighting chance. A hundred
retries to copy a non existent file will result in 100 failures to copy the
file.

Ron W
p said:
We have a upsized access 2000 (ODBC front SQL Back) that we permit users to
"Attach" files to the app. Attach button allows users to pick a file (xls,
doc, pdf, csv) on their compuer, which gets copied to a server share,
verifies file exists in share, then UNC Path gets set for each attachment.
We run this on Citrix for 20 offices and 100 users around country but some
remote (geographically) users have problems attaching files Err 75 etc. I
added a delay of 100ms in error handler which can get called 5 times. When
they send me a file I can always attach this locally. Any ideas how to
handling the errors better or processing file copy/retries better? P

' UNC file root
strDestFile = "\\Server1\Pipeline\ServPickingTicket"
' 1)counter to count retries in case of err during filecopy.
Dim ErrOpenCntr As Integer
Dim ErrCounter As Integer
ErrOpenCntr = 0
ErrCounter = 0
On Error GoTo ErrorHandler
' check for Purchasing Material code Explosion file
If Not IsNull([SysFileAttachServPickTicketUNC]) Then
' File is Missing but path was found
' Check for valid path 5 more times, then fail
Do While isPathOk([SysFileAttachServPickTicketUNC]) = False
' count retrys
ErrOpenCntr = ErrOpenCntr + 1
' if file open retried 5 times then quit.
If ErrOpenCntr >= 5 Then
MsgBox "The file " & [SysFileAttachServPickTicketUNC]
&
"
can not be opened right now but please retry again."
Exit Sub
End If
' pause 100ms
Sleep 100
Loop
' Open file if found on a retry.
Call fHandleFile([SysFileAttachServPickTicketUNC], WIN_NORMAL)
Else ' File is not there open one and store
' Call getPath with standard windows file open
' Make list of file filters
' FilterName & Null & FileFilter & Null
' String needs to end with 2 nulls
' added excel, word, text and all files
strFilter = "Excel Files (*.xls,*.csv)" & vbNullChar &
"*.xl?;*.csv" & vbNullChar
strFilter = strFilter & "Word Files (*.doc)" & vbNullChar & "*.doc"
& vbNullChar
strFilter = strFilter & "Adobe Acrobat Files (*.pdf)" & vbNullChar
& "*.pdf" & vbNullChar
strFilter = strFilter & "Text Documents (*.txt)" & vbNullChar &
"*.txt" & vbNullChar
strFilter = strFilter & "All Files (*.*)" & vbNullChar & "*.*" &
String(2, vbNullChar)

strSrcFile = getFile(, strFilter, , "Choose File Above")
For i = 1 To Len(strSrcFile)
If Asc(Mid(strSrcFile, i, 1)) <> 0 Then
strTempName = strTempName + Mid(strSrcFile, i, 1)
End If
Next i
strSrcFile = strTempName
' if cancel was pressed exit sub
If Len(strSrcFile) < 1 Then
Exit Sub
End If

' Check Quote# and make sure not empty string
If Not IsNull(Me.Reference_.Value) Then
strQuote = Trim(Me.Reference_)
Else
MsgBox "This record must have a quote number first!"
Exit Sub
End If

' get file extension including dot
strFileExt = Right(strSrcFile, Len(strSrcFile) -
InStrRev(strSrcFile, ".", , vbTextCompare) + 1)
Trim (strFileExt)
' append together full dest file name
strDestFile = strDestFile + strQuote + strFileExt
'MsgBox "DestFile = " & strDestFile

' FileCopy "strsrc", "strdest"
FileCopy strSrcFile, strDestFile
' Verify file copied then update db with path and change button
If isPathOk(strDestFile) = True Then
' set value in Tracklog
[SysFileAttachServPickTicketUNC] = strDestFile

' Change button caption
cmdServPickTic.Caption = "View File"
cmdServPickTic.FontBold = True
cmdServPickTic.ForeColor = vbRed
Else
' warn user file did not Copy
MsgBox "The file=" & strDestFile & " did NOT copy successfully.
Please retry."
End If
End If

' 3) exit when success add after last end if and end sub
Exit Sub

ErrorHandler:
' increment and retry 5 times
ErrCounter = ErrCounter + 1
If ErrCounter <= 5 Then
' pause 100ms
Sleep 100
' retry err provoking statement
Resume
Else
' reset counter
ErrCounter = 0
' After 5 times
MsgBox "There was a problem attaching this file, Please try
again
at
a different time. Error = " & Err.Number & " Description=" &
AccessError(Err.Number)
' exit sub because of err
Exit Sub
End If
End Sub
 
R

Ron Weiner

You might want to make sure that the Filespec returned buy the File Dialog
is returning a "good" value. IE it is returning a filespec from the clients
machine.

How do you limit your users from using the File Dialog to peruse and select
files on the Citrix server, and other parts of your internal network?

Oooopps I think just saw the problem with your code!

It appears you are not preapending a \\Client\ to the head of the source
filespec when you invoke the copy command. Therefore it will attempt to copy
the file from the filespec ON THE CITRIX SERVER not the remote users hard
drive. In almost every case the file will not be there and the copy will
fail. Remember the program is being run on the server NOT the users
machine. A good filespec for coping a file from a remote users hard drive
might look like: \\Client\C:\SomeDirectory\AnotherDirectory\Filename.txt.
If the source filespec doesn't the have the \\Client\ then the copy command
will attempt to copy the file from the C: drive of the Citrix Server.

Ron W

p said:
Ron,

I will try adding this code to check the file just before copying. Thanks
for suggestion.

I have them use a file dialog box to pick the file to copy. 90% have the
files, to attach, stored on their local machine "My Documents". Sometimes
during errors, I have shadowed them, watched them click an "Attach" button,
browse to file on their HD, click "OK" to copy and get that error? I dont
think they are using using laptops so HD powerdown should not occur. The
network does not appear to have problems, am able to ping both ways. The
server share is actually a NAS and wonder if that could affect something.
But it seems the only users who have problems are remote so there is no
common thread there except distance?

Thanks Again
P


Ron Weiner said:
In a previous life I had to allow Citrix users to upload files to a server
share from access. In the two years that this app was in production I don't
think I ever got more than a handful of calls from users that had trouble.
In every case the cause of the trouble was that the user did not enter the
source name of the file accurately, and the app would throw a Path/File
Access error. What you can do to isolate this is to attempt a Dir() on the
user's source file before the copy operation. Something like:

If Len(Dir("\\Client\" & FullClientSourceFilespec)) > 0 Then
' Attempt to Copy the file as the Source File Exists
FileCopy ("\\Client\" & FullClientSourceFilespec,
"\\yourUNCShare"
&
FilenamePartOfFullClientSourceFilespec
'... and all of the other stuff you have to do
Else
MsgBox "Error: Source filename does not exist!", vbExclamation, "
Bad Filename"
End If

Something like this will give you at least a fighting chance. A hundred
retries to copy a non existent file will result in 100 failures to copy the
file.

Ron W
users
to
etc.
I
added a delay of 100ms in error handler which can get called 5 times. When
they send me a file I can always attach this locally. Any ideas how to
handling the errors better or processing file copy/retries better? P

' UNC file root
strDestFile = "\\Server1\Pipeline\ServPickingTicket"
' 1)counter to count retries in case of err during filecopy.
Dim ErrOpenCntr As Integer
Dim ErrCounter As Integer
ErrOpenCntr = 0
ErrCounter = 0
On Error GoTo ErrorHandler
' check for Purchasing Material code Explosion file
If Not IsNull([SysFileAttachServPickTicketUNC]) Then
' File is Missing but path was found
' Check for valid path 5 more times, then fail
Do While isPathOk([SysFileAttachServPickTicketUNC]) = False
' count retrys
ErrOpenCntr = ErrOpenCntr + 1
' if file open retried 5 times then quit.
If ErrOpenCntr >= 5 Then
MsgBox "The file " &
[SysFileAttachServPickTicketUNC]
&
"
can not be opened right now but please retry again."
Exit Sub
End If
' pause 100ms
Sleep 100
Loop
' Open file if found on a retry.
Call fHandleFile([SysFileAttachServPickTicketUNC], WIN_NORMAL)
Else ' File is not there open one and store
' Call getPath with standard windows file open
' Make list of file filters
' FilterName & Null & FileFilter & Null
' String needs to end with 2 nulls
' added excel, word, text and all files
strFilter = "Excel Files (*.xls,*.csv)" & vbNullChar &
"*.xl?;*.csv" & vbNullChar
strFilter = strFilter & "Word Files (*.doc)" & vbNullChar & "*.doc"
& vbNullChar
strFilter = strFilter & "Adobe Acrobat Files (*.pdf)" & vbNullChar
& "*.pdf" & vbNullChar
strFilter = strFilter & "Text Documents (*.txt)" & vbNullChar &
"*.txt" & vbNullChar
strFilter = strFilter & "All Files (*.*)" & vbNullChar & "*.*" &
String(2, vbNullChar)

strSrcFile = getFile(, strFilter, , "Choose File Above")
For i = 1 To Len(strSrcFile)
If Asc(Mid(strSrcFile, i, 1)) <> 0 Then
strTempName = strTempName + Mid(strSrcFile, i, 1)
End If
Next i
strSrcFile = strTempName
' if cancel was pressed exit sub
If Len(strSrcFile) < 1 Then
Exit Sub
End If

' Check Quote# and make sure not empty string
If Not IsNull(Me.Reference_.Value) Then
strQuote = Trim(Me.Reference_)
Else
MsgBox "This record must have a quote number first!"
Exit Sub
End If

' get file extension including dot
strFileExt = Right(strSrcFile, Len(strSrcFile) -
InStrRev(strSrcFile, ".", , vbTextCompare) + 1)
Trim (strFileExt)
' append together full dest file name
strDestFile = strDestFile + strQuote + strFileExt
'MsgBox "DestFile = " & strDestFile

' FileCopy "strsrc", "strdest"
FileCopy strSrcFile, strDestFile
' Verify file copied then update db with path and change button
If isPathOk(strDestFile) = True Then
' set value in Tracklog
[SysFileAttachServPickTicketUNC] = strDestFile

' Change button caption
cmdServPickTic.Caption = "View File"
cmdServPickTic.FontBold = True
cmdServPickTic.ForeColor = vbRed
Else
' warn user file did not Copy
MsgBox "The file=" & strDestFile & " did NOT copy successfully.
Please retry."
End If
End If

' 3) exit when success add after last end if and end sub
Exit Sub

ErrorHandler:
' increment and retry 5 times
ErrCounter = ErrCounter + 1
If ErrCounter <= 5 Then
' pause 100ms
Sleep 100
' retry err provoking statement
Resume
Else
' reset counter
ErrCounter = 0
' After 5 times
MsgBox "There was a problem attaching this file, Please try
again
at
a different time. Error = " & Err.Number & " Description=" &
AccessError(Err.Number)
' exit sub because of err
Exit Sub
End If
End Sub
 
P

p

Ron,

We do not normally restrict users browsing since some users store files on
local machine and some on network drives, depends on user preferences.

Citrix users see a a mapped drive V: "C$ on Client (V:)" as their local hard
drive mapping in the "Look In" dropdown list at top. Normally they use the
V: drive to navigate to their remote Citrix client PC while everything runs
on Citrix servers. We have had this setup for at around a year and it works
pretty good. I had to keep adding error checking code to handle retries a
few times. I will add your suggestion to verify the file, before copy.

Thanks!
P

Ron Weiner said:
You might want to make sure that the Filespec returned buy the File Dialog
is returning a "good" value. IE it is returning a filespec from the clients
machine.

How do you limit your users from using the File Dialog to peruse and select
files on the Citrix server, and other parts of your internal network?

Oooopps I think just saw the problem with your code!

It appears you are not preapending a \\Client\ to the head of the source
filespec when you invoke the copy command. Therefore it will attempt to copy
the file from the filespec ON THE CITRIX SERVER not the remote users hard
drive. In almost every case the file will not be there and the copy will
fail. Remember the program is being run on the server NOT the users
machine. A good filespec for coping a file from a remote users hard drive
might look like: \\Client\C:\SomeDirectory\AnotherDirectory\Filename.txt.
If the source filespec doesn't the have the \\Client\ then the copy command
will attempt to copy the file from the C: drive of the Citrix Server.

Ron W

p said:
Ron,

I will try adding this code to check the file just before copying. Thanks
for suggestion.

I have them use a file dialog box to pick the file to copy. 90% have the
files, to attach, stored on their local machine "My Documents". Sometimes
during errors, I have shadowed them, watched them click an "Attach" button,
browse to file on their HD, click "OK" to copy and get that error? I dont
think they are using using laptops so HD powerdown should not occur. The
network does not appear to have problems, am able to ping both ways. The
server share is actually a NAS and wonder if that could affect something.
But it seems the only users who have problems are remote so there is no
common thread there except distance?

Thanks Again
P


enter
the on
the "\\yourUNCShare"
vbExclamation,
"
Bad Filename"
End If

Something like this will give you at least a fighting chance. A hundred
retries to copy a non existent file will result in 100 failures to
copy
the
file.

Ron W
We have a upsized access 2000 (ODBC front SQL Back) that we permit users
to
"Attach" files to the app. Attach button allows users to pick a file (xls,
doc, pdf, csv) on their compuer, which gets copied to a server share,
verifies file exists in share, then UNC Path gets set for each attachment.
We run this on Citrix for 20 offices and 100 users around country
but
some
remote (geographically) users have problems attaching files Err 75
etc.
I
added a delay of 100ms in error handler which can get called 5 times.
When
they send me a file I can always attach this locally. Any ideas how to
handling the errors better or processing file copy/retries better? P

' UNC file root
strDestFile = "\\Server1\Pipeline\ServPickingTicket"
' 1)counter to count retries in case of err during filecopy.
Dim ErrOpenCntr As Integer
Dim ErrCounter As Integer
ErrOpenCntr = 0
ErrCounter = 0
On Error GoTo ErrorHandler
' check for Purchasing Material code Explosion file
If Not IsNull([SysFileAttachServPickTicketUNC]) Then
' File is Missing but path was found
' Check for valid path 5 more times, then fail
Do While isPathOk([SysFileAttachServPickTicketUNC]) = False
' count retrys
ErrOpenCntr = ErrOpenCntr + 1
' if file open retried 5 times then quit.
If ErrOpenCntr >= 5 Then
MsgBox "The file " &
[SysFileAttachServPickTicketUNC]
&
"
can not be opened right now but please retry again."
Exit Sub
End If
' pause 100ms
Sleep 100
Loop
' Open file if found on a retry.
Call fHandleFile([SysFileAttachServPickTicketUNC], WIN_NORMAL)
Else ' File is not there open one and store
' Call getPath with standard windows file open
' Make list of file filters
' FilterName & Null & FileFilter & Null
' String needs to end with 2 nulls
' added excel, word, text and all files
strFilter = "Excel Files (*.xls,*.csv)" & vbNullChar &
"*.xl?;*.csv" & vbNullChar
strFilter = strFilter & "Word Files (*.doc)" & vbNullChar &
"*.doc"
& vbNullChar
strFilter = strFilter & "Adobe Acrobat Files (*.pdf)" &
vbNullChar
& "*.pdf" & vbNullChar
strFilter = strFilter & "Text Documents (*.txt)" &
vbNullChar
"*.*"
&
String(2, vbNullChar)

strSrcFile = getFile(, strFilter, , "Choose File Above")
For i = 1 To Len(strSrcFile)
If Asc(Mid(strSrcFile, i, 1)) <> 0 Then
strTempName = strTempName + Mid(strSrcFile, i, 1)
End If
Next i
strSrcFile = strTempName
' if cancel was pressed exit sub
If Len(strSrcFile) < 1 Then
Exit Sub
End If

' Check Quote# and make sure not empty string
If Not IsNull(Me.Reference_.Value) Then
strQuote = Trim(Me.Reference_)
Else
MsgBox "This record must have a quote number first!"
Exit Sub
End If

' get file extension including dot
strFileExt = Right(strSrcFile, Len(strSrcFile) -
InStrRev(strSrcFile, ".", , vbTextCompare) + 1)
Trim (strFileExt)
' append together full dest file name
strDestFile = strDestFile + strQuote + strFileExt
'MsgBox "DestFile = " & strDestFile

' FileCopy "strsrc", "strdest"
FileCopy strSrcFile, strDestFile
' Verify file copied then update db with path and change button
If isPathOk(strDestFile) = True Then
' set value in Tracklog
[SysFileAttachServPickTicketUNC] = strDestFile

' Change button caption
cmdServPickTic.Caption = "View File"
cmdServPickTic.FontBold = True
cmdServPickTic.ForeColor = vbRed
Else
' warn user file did not Copy
MsgBox "The file=" & strDestFile & " did NOT copy
successfully.
Please retry."
End If
End If

' 3) exit when success add after last end if and end sub
Exit Sub

ErrorHandler:
' increment and retry 5 times
ErrCounter = ErrCounter + 1
If ErrCounter <= 5 Then
' pause 100ms
Sleep 100
' retry err provoking statement
Resume
Else
' reset counter
ErrCounter = 0
' After 5 times
MsgBox "There was a problem attaching this file, Please try again
at
a different time. Error = " & Err.Number & " Description=" &
AccessError(Err.Number)
' exit sub because of err
Exit Sub
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top