open pdf based on form fields

mitchem1

Registered User.
Local time
Today, 17:36
Joined
Feb 21, 2002
Messages
153
Would it be possible to open a .pdf file based on what is found in two different fields on my form? For example, I have a form that searches for Land Acquisition records. When a record is returned, two of the fields are County and Route. I would like to have a button that opens the appropriate .pdf.
The .pdf files are stored in the following method: c:\LandAcq\County|Route
So if my search returned a record where County=Cook and Route=I94, the button should open the .pdf(s) located in c:\LandAcq\Cook\I94.
Sorry if confusing and thanks in advance.
 
You can do that with ease, just do a search on File System Object (fso), there are many posts (or semi-tutorials as i call them) that will show you how to loop through a directory. from there you can just check each file extension and with an "if" statement you can open the file if it is a .pdf extension
 
Last edited:
try this code:

Code:
Private Sub Command1_Click()
Dim tbFile As String
Dim Path As String
Dim FFile As String


Path = Me.county 'this assumes that county is your field name
tbFile = ("c:\LandAcq\County\")
FFile = tbFile & path
    
OpenFile (FFile)

End Sub

and

Code:
[CODE]Private Sub Command2_Click()
Dim tbFile As String
Dim Path As String
Dim FFile As String


Path = Me.route 'this assumes that route is your field name
tbFile = ("c:\LandAcq\County\")
FFile = tbFile & path
    
OpenFile (FFile)

End Sub
[/CODE]

if it doesnt work. zip the db and attach it. I can look at it

Bones
 
I think you might need to try this one:

Code:
Private Sub Command2_Click()
Dim tbFile As String
Dim Path As String
Dim Ext as string
Dim FFile As String

ext = (".pdf")
Path = Me.route 'this assumes that county is your field name
tbFile = ("c:\LandAcq\County\")
FFile = tbFile & path & ext
    
OpenFile (FFile)

Private Sub Command1_Click()
Dim tbFile As String
Dim Path As String
Dim Ext as string
Dim FFile As String

ext = (".pdf")
Path = Me.route 'this assumes that route is your field name
tbFile = ("c:\LandAcq\route\")
FFile = tbFile & path & ext
    
OpenFile (FFile)

End Sub
 
Thanks for the help Bones.
However, there will only be one command button. When clicked it will need to look at both the County and Route fields and then go find the .pdf file. For example, if County=Jackson and Route=US45, it would find the .pdf(s) in this location: c:\LandAcq\Jackson\US45
Thanks again.
 
you should be able to use the code and tweek it a little. If you want attach the file and I will look at it.
 

Users who are viewing this thread

Back
Top Bottom