1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Displaying an Attachment Query in a Form

Discussion in 'Business Applications' started by JaschaMuller, Sep 27, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. JaschaMuller

    JaschaMuller Thread Starter

    Joined:
    Sep 27, 2011
    Messages:
    6
    Hi
    I am a true beginner in access programming, so excuse if my methods isn't the best, and any advice would be much appreciated.

    My main problem is displaying a Query I did on an attachment field in my main table on a form.
    This is what i am working with:
    Access 2007
    My main table name : Table2
    Attachment column name in Table2 : Target_photo
    Query name: QuerySpecGraph (Query on the attachment field)

    The query works perfectly fine when I run it and gives me the correct result. Now to display the query on the form I added an new attachment under controls and edited the control source to display the query results.

    I used the function dlookup:

    =Dlookup("Target_photo","QuerySpecGraph")

    I tried similar code on a text box, with a text Query and that worked fine. However it does not want to work for the attachment.

    Then I tried to analyze the situation to see if the query is the problem, so changed the attachments control source to:

    =Dlookup("Target_photo","Table2")

    this was to see if even a basic dlookup function works in the attachments control source, but yet again the attachments box stays empty (Again I tested the simple dlookup function with a text box to see if my table is the problem, but the textbox's dlookup works fine)

    I do not know what I am doing wrong, or if it is even possible to do what im trying to do! Any advice would be much appreciated, and if there is away around this I will gladly explain in more detail what im trying to do.

    Thanx
    JaschaMuller
     
  2. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    19,684
    JaschaMuller, welcome to the Forum.
    I am afraid I can't help you with the Access 2007 "Attachment" field displaying the photo on a form as I have no experience with Access 2007.
    I would have though that the field should display the photo on the form.
    However I can help you with the old fashioned method of displaying a photo on a form, but it would mean changing the field type to a Text field to store the full "Path" to the photo.
    The technique uses some simple VBA code to display the photo.
     
  3. JaschaMuller

    JaschaMuller Thread Starter

    Joined:
    Sep 27, 2011
    Messages:
    6
    Hi OBP, thank you for the reply!
    Well if my method is not going to work, i will have to resort to your method.... My only problem is that, I am going to distribute my database, so the file paths of the attachments is going to change. So my question then is, is the file paths hard coded (static) or is it related to the name (Dynamic)? and will the paths change as the attachments change?
    Thanks
     
  4. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Links to files like pictures in Access are based on the physical location that the file is sitting and is hard coded in the table. If the file location changes the link is broken.
     
  5. JaschaMuller

    JaschaMuller Thread Starter

    Joined:
    Sep 27, 2011
    Messages:
    6
    So if I understand you correctly, if you move the attachment files, the attachment links breaks in my the main table?
     
  6. JaschaMuller

    JaschaMuller Thread Starter

    Joined:
    Sep 27, 2011
    Messages:
    6
    Sorry, Im asking this because it is my understanding that if you enter an attachment into to table, the attachment is contained in the data base, not through the file path. That is why I want to stay away from file paths and keep the database dynamic
    Thnks
     
  7. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    19,684
    It doesn't matter what kind of linking method that you use (Hyperlink, Path or Attachment) if the user moves the object file the link will not work.
    You can actually store the object in the database table as an OLE Object, but it uses a large amount of database space and you have to "Insert" each object.
     
  8. JaschaMuller

    JaschaMuller Thread Starter

    Joined:
    Sep 27, 2011
    Messages:
    6
    Tanks for reply! Yes I understand it, I am using the OLE object thanx (Attachment) ! I actually figured out my original problem! Rookie mistake!
    I have a new question though!
    I just want to know if it is possible to add an attachment to my main table from a form. For example through user interaction. Its the same principal for example if a user enters something in a text box and presses a button (with VBA code of course) and that gets entered into the main database table as an entry.
    Thanx !
     
  9. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    19,684
    They use the Menu and Insert as you do in the table.
    But it probably can be done with VBA as well.
     
  10. JaschaMuller

    JaschaMuller Thread Starter

    Joined:
    Sep 27, 2011
    Messages:
    6
    Menu and Insert from a Form? Can you please tell me how that is done? This is now for a user to add his/her own attachment to my main table through a Form hey?
    Thanx!
     
  11. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    19,684
    There does not appear to be the same option in Access 2007.
     
  12. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1019573

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice