dellehurley
Board Regular
- Joined
- Sep 26, 2009
- Messages
- 171
- Office Version
- 365
- Platform
- Windows
Hi
I am having trouble with this code below, the if isnull section. The code is to open the associated file after double clicking on the row. The issue arises when you miss double clicking the filename's row (generally by hitting the header row) an error "invalid use of null" displays. I simply wanted a message box to pop up saying that it was invalid and to try again or for nothing to happen you try again.
With the code below the message box opens after every doubleclick, regardless of if it is valid or not.
NB. The "one error goto" is working correctly and is seperate from the Null issue.
Thanks for your help.
Dannielle
I am having trouble with this code below, the if isnull section. The code is to open the associated file after double clicking on the row. The issue arises when you miss double clicking the filename's row (generally by hitting the header row) an error "invalid use of null" displays. I simply wanted a message box to pop up saying that it was invalid and to try again or for nothing to happen you try again.
With the code below the message box opens after every doubleclick, regardless of if it is valid or not.
VBA Code:
Private Sub lstDatabase_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim folderName As String
Dim FileName As String
Dim answer As VbMsgBoxResult
folderName = ThisWorkbook.Path & "\"
FileName = Me.lstDatabase.Value
If IsNull(FileName) = False Then
MsgBox "Invalid!" & vbCrLf & "Try Again", vbOKOnly
End If
On Error GoTo NoFile
answer = MsgBox("Would you like to open" & vbCrLf & FileName & "?", vbOKCancel, "Multi Media Database")
If answer = vbYes Then
ThisWorkbook.FollowHyperlink folderName & FileName
Exit Sub
End If
NoFile:
MsgBox "File " & FileName & vbCrLf & " is not found in Folder.", vbOKOnly + vbCritical, "File Not Found"
End Sub
Thanks for your help.
Dannielle