Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    charlea is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    17

    Make a image visible/not visible based on a value in a report

    I'm printing work orders tickets which have different wording depending on the product being requested. I have two images, one with each type of wording necessary to produce the correct chain of events in the shop to get the order filled, one is over laying the other in design view. When the value in a field reads, just for simplicity say black, I want one image to be visible on the ticket and when the value is white I want the other image to be visible.


    How would you accomplish this?

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,474
    OnCurrent and AfterUpdate events on form(change Yourfield to name of field)

    If me.YourField = "Black" Then
    me.Image1.visible = True
    Me.Image2.visible = False
    Else
    Me.Image1.visible = False
    Me.Image2.visible = True
    End If

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    An alternative code structure not using If Then:

    Me.Image1.Visible = Me.YourField = "Black"
    Me.Image2.Visible = Me.YourField = "White"
    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
    charlea is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    17
    Are Image1 and Image2 literal or should they be the name I have given to each image?

  5. #5
    charlea is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    17
    When I select my image Property then Event it only gives me options of: On Click, On Dbl Click, On Mouse down, On Mouse Up, On Mouse over
    Not On Current.

  6. #6
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,474
    Those go on the Form Property Events, not those image controls. The names are the ones you have, not the ones we put in there as sample code.

  7. #7
    charlea is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    17
    Quote Originally Posted by Bulzie View Post
    Those go on the Form Property Events, not those image controls.
    In this quote, what are those, and should the images be on a Form? The Record Source for the Report is TicketQ with the Report being TicketThermoInjectR.ProductCategory

    If I select the report and not the Image, the Property Sheet has On Current.......so I put the second piece of code in that place.

    Private Sub Report_Current()
    Me.InjectedTicketImage.Visible = Me.ProductCategory = "Injected"
    Me.ThermoformedTicketImage.Visible = Me.ProductCategory = "Thermoformed"
    End Sub

    I didn't work. After Update wasn't and option.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Ooops, should have realized you wanted this in a report.

    Doing it on a form would only work nice for a form in Single View, not Continuous and not Datasheet.

    There is some code out there to do this in report. However, that was necessary before the Image Control had ControlSource property. Easier options:

    1. embed the two images into attachment fields of a table that has only the one record, then include that table in report RecordSource,

    2. images are in external location and expression in Image control ControlSource references file path/name

    In either case, conditional expression in an Image control ControlSource will determine which image displays.
    Last edited by June7; 07-28-2017 at 02:12 PM.
    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.

  9. #9
    charlea is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    17
    The goal then is to change the image so that it can be used in a conditional expression?
    Could you please give me a step by step on how to do the first option?
    Thanks for you help!

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I'm curious, what do these images show? What file type - jpg, png, bmp?

    My idea for Option 1 would use a table, call it Images, with 2 Attachment fields named Image1 and Image2, and there would be only one record.

    Put an Image Control on the report. Drag from the Design tab and when the file browser opens, just cancel it. Then options for using Images table:

    1. Use DLookup() in ControlSource property: =DLookup(IIf([fieldname]="black","Image1","Image2"), "Images")

    2. Include the Images table in report RecordSource without a JOIN clause to cause the single Images record to associate with every record of other data source, something like:
    SELECT tablename.*, Images.* FROM tablename, Images;
    Then in ControlSource property: =IIf([fieldname]="black", [Image1], [Image2])

    If images are external files, ControlSource could be: ="your image folder path here" & IIf([fieldname]="black", "image1.jpg", "image2.jpg")

    These work great with form and report in Report View, but in Print Preview only shows black boxes if the image files are large.
    Regardless, you will probably see a difference in image quality between Report View and Print Preview.
    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.

  11. #11
    charlea is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    17
    The images are bmp size 68,634 bytes and they show abt 6 different text, about 2x3 inches each, with lines after each word which are initialed as each operation is done until the product is finished. (like trimmed _____ )

    I hadn't used Attachment fields so I'm feeling this out. I have the images saved in a file. I have made a table called ImagesT with an ID data type auto, and one field called Images with data type attachment. I'm a little unsure here, your direction said,"there would be only one record." Do I have it right so far?

  12. #12
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Do you have to use images when you're just showing text? Dealing with text only should be far easier.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    My instructions stated to have two Attachment fields. Install 1 image in each field.

    I agree with Micron, if the images show only text then just use a conditional statement in textbox. That's why I asked what the images show.
    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.

  14. #14
    charlea is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    17

    Changing values changing images

    There are two types of ticket that I want to be able to print with one button as a report. There are 4 per sheet.
    Ticket 1:
    section 1
    OrderNumber PONumber CurrentDate Background color blue
    ProductName CustomerName
    ____________________________________________
    section 2
    Space for Barecode
    _____________________________________________
    section 3
    Injected ____txt_____ Qty Ordered __RecordSource query
    Trimmed _txt__ Box __RecordSource query
    Inspected _txt__ Box __RecordSource query
    Eyeletted _txt__ Target Delivery __RecordSource query
    Trim/inspect _txt__ Note __RecordSource query
    Count/Box _txt__
    Notes __________txt____________


    Ticket 2:
    OrderNumber PONumber CurrentDate Background color pink
    ProductName CustomerName
    _____________________________________________
    Space for Barecode

    _____________________________________________
    Cooked____txt_____ Qty Ordered __RecordSource query
    Routed Drilled _txt__ Box __RecordSource query
    Buff/Flapp _txt__ Target Delivery __RecordSource query
    1st inspection _txt__ Note __RecordSource query
    Assembled _txt__
    Final insp __txt__ Notes __________txt____________


    I have used conditional formatting to change the background color in the first section from black/white as value changes. This makes the different tickets easily recognizable.
    The third section right column information is enough the same and also dependent on a Record Source so that nothing needs to be change.
    The third section left column has major differences in needs as the Product is going through the production process and employees are initialing or marking the ticket.

    The image is of this third section left column which I'm attempting to change as the black/white value changes.

    I'm open to whatever works best.
    About your instructions, "2 Attachment fields named Image1 and Image2, and there would be only one record."
    Could you please define 'Attachment fields' and, to me, 'one record' would mean if I were using auto number there would be only one record with both images in one field. Sorry, just got lost in the wording.

    Lost in the forest but will get found with help.
    Last edited by charlea; 08-02-2017 at 12:48 PM. Reason: I wasn't finished

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    What does that tell us? Where is the image? Is that text one image? What is the other? What is different in the text?
    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.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-27-2016, 10:29 PM
  2. Replies: 16
    Last Post: 03-26-2015, 08:35 PM
  3. Replies: 30
    Last Post: 07-21-2014, 02:46 PM
  4. Visible/Not Visible based on condition VBA
    By BLFOSTER in forum Programming
    Replies: 3
    Last Post: 07-15-2014, 01:29 PM
  5. Replies: 2
    Last Post: 01-06-2011, 04:38 AM

Tags for this Thread

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