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
"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