Denise2020
Member
- Local time
- Today, 07:45
- Joined
- Mar 31, 2020
- Messages
- 82
Hello again, I have, in relation to another post, come upon another error that is confusing me. I have the following If then statement:
The problem is that the error message box pops up even if the the code succeeds. It does what it is supposed to, but still pops up the "message to user" error msgbox (in both instances, whether it is doing the "If" part or the "Else" part) and I cannot figure out why. If I remove the error handler, then the Else part fails with a windows error message (cannot follow link) if the user has not created a folder at the directory as directed.
I am sure it is quite obvious but I am unfortunately not well versed in VBA. Thank you in advance!
Code:
On Error GoTo ErrMsg
If Len(Me.Referens.Value & "") = 0 Then
[Referens] = "#.....Explorer directory path..." & Me.Arendenr
Me.Refresh
Msgbox "....message to user telling them to create a folder in the specified directory"
Application.FollowHyperlink "....Explorer directory path..."
Else
Application.FollowHyperlink ("...Explorer directory path the user created..." & [Arendenr])
End If
On Error Resume Next
ErrMsg:
MsgBox "message to user"
The problem is that the error message box pops up even if the the code succeeds. It does what it is supposed to, but still pops up the "message to user" error msgbox (in both instances, whether it is doing the "If" part or the "Else" part) and I cannot figure out why. If I remove the error handler, then the Else part fails with a windows error message (cannot follow link) if the user has not created a folder at the directory as directed.
I am sure it is quite obvious but I am unfortunately not well versed in VBA. Thank you in advance!