Can I add a filter to a hyperlink?

G

Guest

Hi all,

I'm doing a database on countries and I have a form that has a combo box
from which individual countries can be selected, and fields which are
filtered according to the country selected. I wanted to display pdf files so
I included a command button which when clicked does this, using the following
code:

Private Sub Command192_Click()
Dim strFileName As String

strFileName = "J:\leg er\er projects\Countries by geographical
regions\SEAPFE\Mongolia\Note for the files\" & Me.country & ".pdf"
Application.FollowHyperlink strFileName
End Sub

The pdf dcouments are contained in a sepatrate folder for each country
("Mongolia" here). I would now like to add another control button which opens
the folder containing all the "Notes for the Files" pdf documents, but which
filters according to the country selected in the combo box. So if I select
"Canada" in the combo box, then when I click on the control button the folder
for Canada is opened, and not just the folder for "Mongolia" everytime.
Any help on this would be appreciated. Thanks in advance.
 
J

J

Short answer:

strFileName = "J:\leg er\er projects\Countries by geographical
regions\SEAPFE\" & Me.country & "\Note for the files\" & Me.country &
".pdf"



Better answer:

Create a table called "tblHyperlinks" with one column for the combo
box's bound values and one column for the actual hyperlinks
(Alternatively, if you already have a table for your combo box, just
add a column field for "hyperlinks"). Fill in the bound values with
every possible value for the combo box and then the hyperlinks filed
with the full static hyperlinks (eg. "Mongolia" and "J:\leg er\er
projects\Countries by geographical regions\SEAPFE\Mongolia\Note for the
files\Mongolia.pdf", without the quotes)

Now, when you click the Cmd button, use:

strFileName = Dlookup ( "[HyperlinkPDF]", "tblHyperlinks",
"[ComboBoxBoundColumn]='" & cboBox & "'" )
'If ComboBoxBoundColumn is a set of strings

'(-OR-)

strFileName = Dlookup ( "[HyperlinkPDF]", "tblHyperlinks",
"[ComboBoxBoundColumn]=" & cboBox)
'If ComboBoxBoundColumn is a set of numbers



....and then run the code that uses that strFileName. The advantage to
this is any administrator can open up the table with the Combo box
values and sift through the hyperlinks directly, in case your network
drive letter gets changed or something. The average computer user can
be taught to manipulate tables for updating, but will get frightened if
you show them code.

BONUS HOMEWORK: To prevent error crashing when files/folders get moved
before the program can be updated, look up the Nz() and Dir() commands
to actually check if folders/files exist. You can then open them if
they do exist, or just display an error message if they have been
moved.

Cheers,
~J
 
G

Guest

Thanks very much for your detailed and well laid-out answer, it worked great!

J said:
Short answer:

strFileName = "J:\leg er\er projects\Countries by geographical
regions\SEAPFE\" & Me.country & "\Note for the files\" & Me.country &
".pdf"



Better answer:

Create a table called "tblHyperlinks" with one column for the combo
box's bound values and one column for the actual hyperlinks
(Alternatively, if you already have a table for your combo box, just
add a column field for "hyperlinks"). Fill in the bound values with
every possible value for the combo box and then the hyperlinks filed
with the full static hyperlinks (eg. "Mongolia" and "J:\leg er\er
projects\Countries by geographical regions\SEAPFE\Mongolia\Note for the
files\Mongolia.pdf", without the quotes)

Now, when you click the Cmd button, use:

strFileName = Dlookup ( "[HyperlinkPDF]", "tblHyperlinks",
"[ComboBoxBoundColumn]='" & cboBox & "'" )
'If ComboBoxBoundColumn is a set of strings

'(-OR-)

strFileName = Dlookup ( "[HyperlinkPDF]", "tblHyperlinks",
"[ComboBoxBoundColumn]=" & cboBox)
'If ComboBoxBoundColumn is a set of numbers



....and then run the code that uses that strFileName. The advantage to
this is any administrator can open up the table with the Combo box
values and sift through the hyperlinks directly, in case your network
drive letter gets changed or something. The average computer user can
be taught to manipulate tables for updating, but will get frightened if
you show them code.

BONUS HOMEWORK: To prevent error crashing when files/folders get moved
before the program can be updated, look up the Nz() and Dir() commands
to actually check if folders/files exist. You can then open them if
they do exist, or just display an error message if they have been
moved.

Cheers,
~J


Hi all,

I'm doing a database on countries and I have a form that has a combo box
from which individual countries can be selected, and fields which are
filtered according to the country selected. I wanted to display pdf files so
I included a command button which when clicked does this, using the following
code:

Private Sub Command192_Click()
Dim strFileName As String

strFileName = "J:\leg er\er projects\Countries by geographical
regions\SEAPFE\Mongolia\Note for the files\" & Me.country & ".pdf"
Application.FollowHyperlink strFileName
End Sub

The pdf dcouments are contained in a sepatrate folder for each country
("Mongolia" here). I would now like to add another control button which opens
the folder containing all the "Notes for the Files" pdf documents, but which
filters according to the country selected in the combo box. So if I select
"Canada" in the combo box, then when I click on the control button the folder
for Canada is opened, and not just the folder for "Mongolia" everytime.
Any help on this would be appreciated. Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top