Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2015
    Posts
    10

    Unanswered: Open PDF associated with value in cmbo box help

    Please help real newb in reguards to VB etc

    Im trying to do the above (open a PDF related to the field selection on the push of a button

    I have a table called "SOP Data" with the following fields
    ID No, Area, Description and Link.

    The ID Field Contains a numeber, EG: SOP045
    Area Field & Description field - Not important at this time
    The Link Field contains a Link to a PDF (this for original plan of clicking clink to open file, I dont belive I need this)

    I have a form (Form1)
    This has a button (Command8)
    and a drop down box associated with the ID NO used to select relitive document.

    I Have a folder containing the PDF files in C:\PDF\
    These are saved as the same no as recorded in the ID No - e.g - SOP045.pdf

    I then used the following code as robbed from other posts:

    Private Sub Command8_Click()
    Dim stAppName As String
    stAppName = "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe"C:\PDF\" & [ID No] & ".pdf"
    Call Shell(stAppName, 1)
    End Sub


    I get a Error and the 1st line is highlighted, the 3rd line also shows in red, I guess this is the errors ?


    Appriciate any help, have been playing with this for a day or so a need some help / advice

    Thankss, hope the above makes sence

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    what is the value of [ID No]?
    ..where is it coming from?
    does that file exist?
    can you examine or dispaly the value of stAppName here. set a breakpoint oint he cide or at the very least use a msgbox. usign a breakpoint and then exzaminiugn the value iunt he immedaite window is preferabel as it measn you can copy and paste the exact value and post it here. to display a value in the immediate window use ?<variablename>, eg ?stAppName

    im guessing the extra " in :-
    Code:
    stAppName = "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe"C:\PDF\" & [ID No] & ".pdf"
    is an artificat of how youve posted the code here. and is in reality a space separating the .exe and c:\.....
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2015
    Posts
    10

    Help PDF Open

    Not sure I understand the question

    1. I have a folder on my hard drive containing pdf documents named as "SOP048.pdf" The location = C:\PDF\SOP048.pdf etc
    2. The user selects a "SOPxxx"
    3. The related PDF opens for review

    DB Structure

    A Table with the field name "ID No" , the data storred in this field relates to the SOP no, thus:

    SOP048
    SOP049
    SOP......

    I assume the code needs to know what programe to run which points to the following , I just guessed from what ive seen in this forum. I assume the second identify the location and id of the pdf to open

    stAppName = "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe"C:\PDF\" & [ID No] & ".pdf"

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    thats all well and good. but you haven't proved that your code is doing what you think it is. it may well be, but what steps have you taken to prove it is correct. its all well and good to assert somethign is doing, but you need to demonstrate to yourself that the code does what you expect.

    if the code you have posted is as per your VBA moduel then there is an error, an additional "
    Code:
    stAppName = "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe"C:\PDF\" & [ID No] & ".pdf"
    if that doesn't clear the problem then its something else
    ..and the most likely cause of that is a difference between what you think your code is and what it actually is.

    problem solving code is taking a small step and prove that code is 'reasonable', ie is doing what it should be doing. Because your code gets modified at runtime you need to demonstrate to yourself that the file is being correctly formed. hence why you need to examine the value of stAppName. NOT the VB code that create stAppName, but the actuall value of stAppname when the error is reported

    if stAppName is being correclty formed then move on to find what else the fault could be.

    it could be that your PDF viewer isn't
    ..the specified version, program (file) name
    ..its possible on other client machines they do not use acrobat reader (they may use Acrobat writer or even some third party file viewer

    shelling out to a third party program on a computer that isn't locked down (in terms of what the software build is), is ALWAYS fraught with problems, and your code ought to handle that. whether you do that through multiple attempts to use different PDF versions, and or wrap calls to the PDF viewer using an error handler is your call

    this is a common problem if you are supporting lots of users with different system configurations. so your code could work on some computers and not on others. you would be safer finding the path to your PDf viewer in the registry or other mechanism.
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Jan 2015
    Posts
    10

    PDF Help

    My 1st line on initial post
    Please help real newb in reguards to VB etc

    I havnt a clue what you are on about, im searching for a solution
    I find what looks like solutions, not understanding how they work
    I edit the stuff that makes sence
    and try the code

    some anserws would help me understand
    some explination of the termanology and how it works would help

    Thanks for your time

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    OK so to rephrase
    right now I don't know where the fault lies
    you don't say what error is displayed when Access halts execution

    it could (must) be that the code is not doing what you think it is.
    that could be becuase the value of stAppname is invalid
    ..I have pointed out to you that you have an extra " in between the acroread.exe and the name of the PDF file to be read. Whether that is a true error or artifact of how you have posted the code here I don't know. well in part because you've ignored that.

    ..it could be that the value you are substituting the [id no] is causing the problem.
    ..becuase either tis the wrong value, it the wrong variable it the wrong piece of information.
    again I don't know because so far you've not tried to examine what the actual value is as opposed to what the code looks like

    ferinstance
    if you had code such as

    Code:
    myID = 'SOP048'
    stAppName = "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe C:\PDF\" & myID & ".pdf"
    then it woudl be clear that stApp woudl be
    C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe C:\PDF\SOP048.pdf

    but i / you we don't know that because [id no] is coming from elsewhere and we don't know what the value is beyond your assertion that it equals SOP048.pdf in a directory called \pdf\ on drive C,

    we don't know that you actually have a file called SOP048.pdf

    we don't know that you have Acrobat reader (AcroRd32.exe) installed in that specific location (C:\Program Files (x86)\Adobe\Reader 10.0\Reader\)

    when diagnosing faults in code that is built at runtime then it helps to see the actual value of the variable, not the VBA code that creates the variable
    ferinstance

    strSQL = 'select userid, username from users where userid = ' & mycombo
    the VBA code looks fine. BUT if userid is an alphanumeric value then although the VBA code compiles its sendign crap data to the SQL engine as alphanumeric columns must be delimited

    in the same vein it may be that the value from mycombo isn't what you expect or thing. again we doin't know what it is as you seem unable to prove (if only to yourself that it is indeed SOP048. its fine and dandy to describe what shoudl be, its another thing altogewther to prove (agin if only to yourself) that your assertions amd expectatiosn are correct.

    we don't know there is a control called [ID No], it coudl actually be IDNo or ID_No
    showing the actual value of the variable will quickly identify what is being sent to the call command.

    asking for the value of the variable is a quick and easy way of seeign if your assumptions are bourne out by what is happening to your program,#####lastly if you are going to be develoiping in Access then you really (and i do mean really) need to get to grips with the debugger. if you don't see yourself doing more than a couple of days developemnt in Access then IOK, bludner about in the dark., if you see yourself spenidng several weeks/ months or more then get to grips wiuth the debugger. it takes away a great deal of the mystrery about development., it can tell you precisely what your code is doing as opposed to what you think its doing.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •