Hello!
I am using the following function to find and link pictures in my database. It works fine, however, if I decide not to attach a picture and choose "cancel" from the window, I get the message "Runtime Error '5' Invalid call or procedure". This will confuse users. I'm don't know how to get around it and am looking for direction. Thank you in advance.
Code:
Public Function GetFileInformation(strPathAndFileName As String)
On Error GoTo errHandler
Dim I As Integer, J As Integer, intCurrPos As Integer, intNextPos As Integer
Dim intFinalPos As Integer, intLength As Integer
intCurrPos = 1
intLength = Len(strPathAndFileName)
For I = 1 To intLength Step intCurrPos
intNextPos = InStr(intCurrPos + 1, strPathAndFileName, "\")
If intNextPos = 0 Then
glFileName = Mid(strPathAndFileName, intCurrPos + 1, intLength)
intFinalPos = intCurrPos
End If
intCurrPos = intNextPos
Next I
glPath = Mid(strPathAndFileName, 1, intFinalPos - 1)
glInitDir = glPath
Exit Function
errHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _
VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error"
End Function