Results 1 to 9 of 9
  1. #1
    JackLeon is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2015
    Posts
    15

    Post How to get logo from a database field to show on the report

    I am trying to access Logo through a table to show dynamically. Here are the details:

    Table Name: Tbl_Generic
    Field Structure:
    Entry_Id (Text)
    Entry_Object (OLE Object)

    Right Clicked on the field "Entry_Object" for the row where Entry_Id was put as 'Logo' (in Database View). Chose 'Insert Object'. A window appeared, chose 'Create from File'. Browsed the logo with PNG extension and checked the Checkbox for 'Link'.

    Added Image Control and put following in ControlSource
    =DLookUp("[Entry_Object]","Tbl_Generic","[Entry_Id] = 'Logo'")



    On executing the report, Image Control shows up blank. Any suggestions on the same would help. Thanks!!

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    first, don't store the image in your database, store the path and file name (or just store the image in the same directory as the database itself and use currentproject.path to get the path)

    second I don't believe you can dlookup an image... but if you are using 2007 there is an easier way shown here:

    http://stackoverflow.com/questions/2...es-using-paths

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I've never used OLEObject data type. I have used Attachment field to store images. An Image control can be bound to Attachment field to display embedded images.

    If not embedding images and just storing in text field the file path/name for external image files, Image control ControlSource property can be an expression that concatenates literal text with field or DLookup expression:
    ="C:\Images\" & DLookUp("[Entry_Object]","Tbl_Generic","[Entry_Id] = 'Logo'")

    A RecordSource could join tables then bind the Image control to field that has the embedded image or file path/name.

    Virtually no VBA code needed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    JackLeon is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2015
    Posts
    15
    @rpeare: Yeah, that is how I have been making it work all this while but was still wondering if their was a way to store the image in db to make the application portable since I have not splitted the db from the application yet which would bound me to place the db at some server.
    @June7: Already tried using 'Attachment' as type for the db field but it yielded the same result as OLE Object which was a blank.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You embedded images into Attachment field? I know Image control can be bound to Attachment field, I just confirmed again. I set ControlSource to the attachment field name, not the attachment FileData component.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    JackLeon is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2015
    Posts
    15
    @June7: Yup. Added a field to the the table Tbl_Generic as Entry_Object1 (Type-Attachment). In Datasheet view, right clicked on the field and using option 'Manage Attachments', added a logo file with extn as PNG. The field showed 1 attachment.
    Now, added Image Control to the report and put =DLookUp("[Entry_Object1]","Tbl_Generic","[Entry_Id] = 'Logo'") in the ControlSource. On executing the report, image control showed up blank.
    Please see if you could figure out the loophole.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Sorry, DLookup won't work with embedded, attached image. As stated in post 3, it would work if you stored only file path/name in a text field for an external file.

    For embedded image, instead build a query that filters to the one Logo record and include that query in the report RecordSource.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    JackLeon is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2015
    Posts
    15
    I have tried using SQL query in report (dummy query mentioned below similar to one used) before too.. Earlier, with OLE Object datatype field, it did not work and even gave error.. with attachment fieldtype, it is not giving any error and is showing up all fields from the OtherTable and the Logo field in the Control Source, but no image got displayed when executed.

    Select * , (Select Entry_Object1 from Tbl_Generic where Entry_Id = "Logo") as Logo from OtherTable.

    Could you please explain using some example of how you would suggest me to use it. Thanks!!

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    SELECT OtherTable.*, Entry_Object1 FROM OtherTable, queryname;

    or to eliminate the saved query object:

    SELECT OtherTable.*, Entry_Object1 FROM OtherTable, (SELECT Entry_Object1 FROM Tbl_Generic WHERE Entry_ID="Logo") AS Q1;

    There is no JOIN clause, this results in a Cartesian relationship - every record from each table/query will associate with every record of other table/query. The image should display with every record if Image control is in detail section. If you want to see the image only once, put Image control in report header section.

    Both work for me.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 01-04-2015, 03:00 PM
  2. changing logo on database
    By joshynaresh in forum Access
    Replies: 5
    Last Post: 03-23-2014, 02:33 AM
  3. Replies: 14
    Last Post: 09-20-2013, 09:36 PM
  4. Replies: 2
    Last Post: 04-19-2012, 12:43 PM
  5. Report won't show added field
    By Jojojo in forum Reports
    Replies: 0
    Last Post: 11-12-2011, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums