Sherman6789
Programmer
We have an Access program that in addition to providing important information in various fields, it allows us to click a button and view a PDF file on the screen within a special form for each record. The way that it is now set up, we have a text box where we type the entire path and pdf file name. ex: g:\voke2011\sectionA\colordata\vokescans\abc050211.pdf.
This worked ok for us when we had only a few files. Now the number of files is increasing so much that the users want to just enter the file name (Ex: abc050211.pdf) and let the program automatically know where the file is located in the proper directory. We would like to leave off the ",pdf", if possible.
The button has the following code in the "ON CLICK" area of the main form:
------------------------------------------------------------------------------------------
Private Sub Form_Current()
strpubBasicPDFPath = IIf(IsNull(Me.BasicPDFPath), "", Me.BasicPDFPath)
End Sub
------------------------------------------------------------------------------------------
Private Sub cmdBasicPDF_Click()
strpubBasicOrPmtPDF = "Basic"
If strpubBasicPDFPath = "" Then
MsgBox "These is no PDF associated with this record.", vbInformation
Exit Sub
End If
DoCmd.OpenForm "frmPDF"
End Sub
------------------------------------------------------------------------------------------
Private Sub cmdPRPDF_Click()
strpubBasicOrPmtPDF = "Pmt"
If strpubPmtPDFPath = "" Then
MsgBox "These is no PDF associated with this record.", vbInformation
Exit Sub
End If
DoCmd.OpenForm "frmPDF"
End Sub
------------------------------------------------------------------------------------------
I should mention that there are two buttons on the main form. One button is for displaying a PDF with basic information "Basic" shown.
The other button is for displaying payment information "Pmt".
The frmPDF form has this code in the "ON OPEN" section:
------------------------------------------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
If strpubBasicOrPmtPDF = "Pmt" Then
If strpubPmtPDFPath = "" Then
Me.WebBrowser0.Navigate ("about:blank")
Else
Me.WebBrowser0.Navigate strpubPmtPDFPath
End If
ElseIf strpubBasicOrPmtPDF = "Basic" Then
If strpubBasicPDFPath = "" Then
Me.WebBrowser0.Navigate ("about:blank")
Else
Me.WebBrowser0.Navigate strpubBasicPDFPath
End If
End If
End Sub
------------------------------------------------------------------------------------------
I don't know if this is important for the operation of the search and PDF display but the following is stored in the "Modules" section of the main form.
------------------------------------------------------------------------------------------
Option Compare Database
Option Explicit
'----Public Variables----
'PDF Path for the Payment PDF
Public strpubPmtPDFPath As String
'PDF Path for the main PDF
Public strpubBasicPDFPath As String
'Determines what button was clicked
'Generates "Pmt" or "Basic"
Public strpubBasicOrPmtPDF As String
------------------------------------------------------------------------------------------
I hope that this is enough information to help you. The main thing that I need to know is how can we embed the location into the program so that the user will only need to enter the file name in the text box. The setup for the payment box is slightly different and I figure that if you can show me how to get the directory path into the program for the Basic side, I can do the Payment side the same way. This is the current path: g:\voke2011\sectionA\colordata\vokescans. All of the PDFs for this program are in this same directory path. Soon, I will move all of these files into a shorter named directory with less subdirectories.
Any assistance that you can give will be appreciated. Thank you.
WRS
This worked ok for us when we had only a few files. Now the number of files is increasing so much that the users want to just enter the file name (Ex: abc050211.pdf) and let the program automatically know where the file is located in the proper directory. We would like to leave off the ",pdf", if possible.
The button has the following code in the "ON CLICK" area of the main form:
------------------------------------------------------------------------------------------
Private Sub Form_Current()
strpubBasicPDFPath = IIf(IsNull(Me.BasicPDFPath), "", Me.BasicPDFPath)
End Sub
------------------------------------------------------------------------------------------
Private Sub cmdBasicPDF_Click()
strpubBasicOrPmtPDF = "Basic"
If strpubBasicPDFPath = "" Then
MsgBox "These is no PDF associated with this record.", vbInformation
Exit Sub
End If
DoCmd.OpenForm "frmPDF"
End Sub
------------------------------------------------------------------------------------------
Private Sub cmdPRPDF_Click()
strpubBasicOrPmtPDF = "Pmt"
If strpubPmtPDFPath = "" Then
MsgBox "These is no PDF associated with this record.", vbInformation
Exit Sub
End If
DoCmd.OpenForm "frmPDF"
End Sub
------------------------------------------------------------------------------------------
I should mention that there are two buttons on the main form. One button is for displaying a PDF with basic information "Basic" shown.
The other button is for displaying payment information "Pmt".
The frmPDF form has this code in the "ON OPEN" section:
------------------------------------------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
If strpubBasicOrPmtPDF = "Pmt" Then
If strpubPmtPDFPath = "" Then
Me.WebBrowser0.Navigate ("about:blank")
Else
Me.WebBrowser0.Navigate strpubPmtPDFPath
End If
ElseIf strpubBasicOrPmtPDF = "Basic" Then
If strpubBasicPDFPath = "" Then
Me.WebBrowser0.Navigate ("about:blank")
Else
Me.WebBrowser0.Navigate strpubBasicPDFPath
End If
End If
End Sub
------------------------------------------------------------------------------------------
I don't know if this is important for the operation of the search and PDF display but the following is stored in the "Modules" section of the main form.
------------------------------------------------------------------------------------------
Option Compare Database
Option Explicit
'----Public Variables----
'PDF Path for the Payment PDF
Public strpubPmtPDFPath As String
'PDF Path for the main PDF
Public strpubBasicPDFPath As String
'Determines what button was clicked
'Generates "Pmt" or "Basic"
Public strpubBasicOrPmtPDF As String
------------------------------------------------------------------------------------------
I hope that this is enough information to help you. The main thing that I need to know is how can we embed the location into the program so that the user will only need to enter the file name in the text box. The setup for the payment box is slightly different and I figure that if you can show me how to get the directory path into the program for the Basic side, I can do the Payment side the same way. This is the current path: g:\voke2011\sectionA\colordata\vokescans. All of the PDFs for this program are in this same directory path. Soon, I will move all of these files into a shorter named directory with less subdirectories.
Any assistance that you can give will be appreciated. Thank you.
WRS