The following code is for "On Got Focus" event of a form which list the PDF Document Reference Titles in sequential order.
Private Sub cmdShowRef_GotFocus()
If IsNull(txtPDFScanLoc) Then
MsgBox "Document is not available due to unknown filename/path."
cmdShowRef.HyperlinkAddress = txtPDFScanLoc
Example: The form in question lists the PDF Document Titles in a sequential list as shown below:
1. Title for Document A
2. Title for Document B
3. Title for Document C
and so on
When the user hovers the mouse pointer over the form (i.e. the list of PDF Document Titles) the mouse pointer changes to hand and when the user clicks over any of the listed document title given the hyperlink for that PDF document exist or populated in the database (i.e. txtPDFScanLoc field holds the path for the PDF Dcoument) the PDF document for the listed Title is opened otherwise a message is displayed.
The issue is when there is no hyperlink populated in the DB for any one of the listed PDF Document Titles on the form (i.e. IsNull(txtPDFScanLoc) computes to TRUE, the desired message is displayed but once you click OK button to close the message dialog box the last opened PDF document opens which is NOT intended.
Example: User first clicks over 1. Title for Document A, since the hyperlink is populated which links to the PDF document the PDF document is opened. But when the user clicks over 2. Title for Document B, whose hyperlink is not populated (i.e. IsNull(txtPDFScanLoc) computes to TRUE with desired message box but once the user clicks OK button to close the message dialog box, the last opened PDF document opens again (i.e. for the 1. Title for Document A).
Logically the code should jumps to End If and should NOT check Else condition...Is there a way for the code to exit out without stepping into Else condition?