Results 1 to 7 of 7

Thread: Ole objects

  1. #1
    Join Date
    Jan 2011
    Posts
    83

    Unanswered: Ole objects

    Hi All,

    In my sales order table, I have added a new field (OLE OBJECT). This is going to store a PDF file of the artwork.

    When I am in a form showing a list of orders, I want to click on the OLE OBJECT which will open up the PDF.

    If there is no PDF in that field, I want to capture this and add my own error message. How do I do this?

    I was thinking along the lines of:

    Event
    DoubleClick on the Ole Object box.

    if Me.PDF_File.value isnull then
    msgbox "No PDF has been added as yet"
    end if

    Thanks
    Simon

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    and the problem you are experiencing is.....?
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2011
    Posts
    83
    I get a very unhelpful "The OLE OBECT is empty" message which I want to change to something easier ofr my users.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    and what code triggers that?
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Jan 2011
    Posts
    83
    no code at all. when the box is clicked to open the pdf and a pdf has not been saved in that field we get the message.

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so i'd suggest you place some code which allows or rejects attempts to load the PDF
    test if the path to the PDF has data in it (it coudl be NULL or have a length of 0 to indicate its empty

    you should also have soem error trapping /checking in to handle the situation where an invalid PDF is stored

    when enabling or disabling the ole control you need to consider when the satte may change

    1) on display of a new row (code goes in the forms on current event)
    2) on change of value in the relevant filename control


    you can set the valeu based ont he filename by say using a function

    Code:
    private sub SetOLEControlState()
      'check if the filename could be valid
      if not isnull(mycontrolname.text) and len(mycomntrolname)>0 then 'it may be valid enable the use of the OLE control
        myOLEObject.enabled = true
      else 'it aint valid so don't allow the PDF to be displayed / call acrobat reader
        myOLEObject.enabled = false
      endif
    end sub
    call that from the on current event

    validating a file is trickier
    what makes a file valid
    ..presumably it must have a .pdf extension
    ..you could shell out using VBScript to check the file exists
    Microsoft Access tips: Determine if a file or folder exists
    having validated the file exists you could set the display PDF controls as required

    bear in mind that a file may look like a PDF and may exists but may not actually be a PDF.
    so place soem error trapping around the call to the PDF reader which handles such errors
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Jan 2011
    Posts
    83
    tyvm. I will have a play with this.

Posting Permissions

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