David Ball
Registered User.
- Local time
- Today, 11:57
- Joined
- Aug 9, 2010
- Messages
- 230
Hi,
The code below opens a PDF selected from a form. Whatever document number appears in the textbox (FICNo) on the form is the document that is opened when the command button is clicked.
It works but I would like to add a message box to say “File not found” if the document number in the textbox has no corresponding document in the folder (ScannedFiles).
How can I modify the code to do this?
Thanks very much
Dave
The code below opens a PDF selected from a form. Whatever document number appears in the textbox (FICNo) on the form is the document that is opened when the command button is clicked.
It works but I would like to add a message box to say “File not found” if the document number in the textbox has no corresponding document in the folder (ScannedFiles).
Code:
[FONT=Calibri][SIZE=3]Option Explicit[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Option Compare Database[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Private Const SW_SHOWNORMAL As Long = 1[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Private Const SW_SHOWMAXIMIZED As Long = 3[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Private Sub CmdOpenDoc_Click()[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]ShellExecute 0, "Open", "C:\Users\David.Ball\Desktop\ScannedFiles\" & Me.FICNo & ".pdf", vbNullString, "C:\", SW_SHOWNORMAL[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]End Sub [/SIZE][/FONT]
How can I modify the code to do this?
Thanks very much
Dave