Using a table value as a parameter...

dsingpur

New member
Local time
Today, 10:24
Joined
Sep 24, 2010
Messages
3
Hello,

I hope this is a simple question that I can get some help with. I have a table full of individual ids and some associated information. For each individual is a .pdf file on my hard drive. I've created a form which displays some information about the individual id and on this form, i'd like to add a command button which when pressed, will open the .pdf file. I've created the command button and can get it to work where it opens up a hard coded .pdf, but don't know how to pass the associated indivdual ID as a parameter. can someone help me? I've included the code for the command button below. 0343766 is the id of the indivdual.


Private Sub Command15_Click()
Dim stAppName As String

Dim varFile As String

varFile = "X:\dir\desiredid\Database Files\\0343766.pdf"

stAppName = "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe " & varFile

Call Shell(stAppName, 1)


End Sub
 
Presuming that value is on the form:

varFile = "X:\dir\desiredid\Database Files\" & Me.TextboxName & ".pdf"
 
Thanks! Very helpful. To clarify, suppose the field name on the form is called ID, then using your code...

varFile = "X:\dir\desiredid\Database Files\" & ID & ".pdf"
 
That might work, but I would use what I posted. The "Me." clarifies that you're referring to a form control. If you just put "ID", are you referring to a variable, a form control, or what? Access may figure it out, but I like to clarify both for Access and anyone else that may look at the code later.
 

Users who are viewing this thread

Back
Top Bottom