Results 1 to 8 of 8
  1. #1
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93

    Display Product Picture

    Hello Everyone
    I want to design a form that displays the picture of the product that are being placed in an order.
    So for example, I have the following tables:

    tblCustomers

    CustomerID CustomerName
    1 John
    2 Gorge
    3 Lisa


    tblProducts
    ProductID ProductName ProductPicture
    1 Product A C:\ ProductPicture\ProductA.jpeg
    2 Product B C:\ ProductPicture\ProductB.jpeg
    3 Product C C:\ ProductPicture\ProductC.jpeg




    tblOrders
    OrderID CustomerID
    1 1
    2 1
    3 2

    tblOrderDetails
    OrderID ProductID Quantity
    1 1 10
    1 2 5
    2 1 20
    2 3 15
    3 3 100


    Then for the user interface, I have a main form and a subform inside the main form. The main form uses the tblOrders as a record source. The subform uses the tblOrderDetails as a record source. After the user enters the order id and customer id on the main form, the focus moves to the subform to select the products for that order. At this point I want the picture of the product to be shown on the main form or subform. So when the user clicks on the down arrow of the combo box and selects for example product A, I want the picture of product A to be shown on the Form.
    I am not planning to store the pictures in my database as an OLE object, because I have many products and I will be using my database on a network, and I have read somewhere that this might slow down the response of my database.
    So I am planning to put an image control on the form and set its control source property to the file path of the product picture that is being selected on the subform. The problem that I was not able to solve is the record source of the subform is tblOrdersDetails and the file path of the product picture is stored on the tblProducts table.
    I hope that this makes sense, if the narrative description is not clear, then I have included a sample database.
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    since the photo is outside the db, you must load the image in the form in the OnCurrent event using the LOADPICTURE command:

    Code:
    sub form_OnCurrent()
    imgbox = loadpicture ([ProductPicture])
    end sub
    then when the user changes records, the new photo will load.

  3. #3
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93
    thanks for your replay ranman256

    I am bit confused, how would the sub code in your previous post would know which product picture to load in the image box ? each order may have many products.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    I thought your example shows the jpg path in the field.
    you can't load external photos for a continuous form.
    this only works for single recs.

    if you want all photos on 1 screen, then you need to load all photos into an OLE field.
    this could fill up the database,but you have all photos at you're fingertips.
    Keep the photo table as an external table to help keep the file size down.

  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,825
    Loading external photos to continuous form does work for me and I use Image control (never used the OLEObject field or control). The ControlSource is:

    ="C:\Users\June\DOT\DCP2012\CorePhotos\" & [ImageNum] & ".jpg"


    Right now your subform container control has SourceObject of tblOrderDetails. You need to build a form for the order details and this form will be the object held by the subform container control. Then options are:

    1. This form's RecordSource is a query that joins tables and Image control references the ProductPicture field:
    SELECT tblOrderDetails.*, tblProducts.* FROM tblProducts RIGHT JOIN tblOrderDetails ON tblProducts.ProductID = tblOrderDetails.ProductID;

    2. A combobox on this form has 3 columns for tblProducts fields. Then an Image control references the ProductPicture column with the combobox column index. Index begins with 0. Assuming that is in column 3:
    =[cbxProduct].[Column](2)

    If your pictures will be on a network, the C:\ path reference won't work. Suggest not storing the path in the record but constructing it in the ControlSource as shown in my db example. You might want to use UNC path reference. This utilizes the server name, not a drive letter so it doesn't matter what drive letter users have assigned. Whether the jpg (or bmp or whatever you use) extension is included in the data or concatenated is for you to decide.

    ="\\ServerName\folderpath\" & [ProductPicture] & ".jpg"
    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
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93
    thanks for your replay June7

    you have answered my question and my issue is solved, plus I have learned allot from your post. Thank you Sir and God bless you.

  7. #7
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93
    just one last question June7, why did you use right join between tblProducts and tblOrderDetails for the form's RecordSource query, why not just use regular join, I have been banging my head against the wall for the last hour trying to figure out the significance of right join with no luck.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    So using option 1? An INNER JOIN requires associated records in both tables for records to show. I wanted the query to show all OrderDetail records even if there were no related image records. Maybe that situation will never occur in your db but I could not be sure.
    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. Display Picture Based on Database Field
    By BlarneyFarneyBegoneyee in forum Programming
    Replies: 6
    Last Post: 01-10-2016, 03:50 PM
  2. Replies: 6
    Last Post: 02-28-2015, 11:57 AM
  3. How to display a picture in a form
    By GeorgeJ in forum Programming
    Replies: 5
    Last Post: 12-09-2014, 03:01 PM
  4. Picture rotating on display Problem
    By justphilip2003 in forum Forms
    Replies: 2
    Last Post: 04-25-2013, 05:44 PM
  5. Replies: 0
    Last Post: 12-14-2009, 09:57 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