Results 1 to 6 of 6
  1. #1
    dsmithe is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    24

    show/hide a picture based on value in table

    I have searched the forums and found a lot of answers to this question but I must be doing something wrong.



    I have a report with an image named voided. The Report's record source is mastertable which has a field named void. If void is true the image should appear. If void is false the image should be hidden. In the reports Detail0 property sheet I have an event procedure for on format. Here is the code:
    Code:
    Private Sub Detail0_Format(Cancel As Integer, FormatCount As Integer)
      If Me.Void = True Then
        Me.voided.Visible = True
      Else
        Me.voided.Visible = False
      End If
    End Sub
    When I run the report I get: Run-time Error 2465: Microsoft Access can't find the field 'Void' referred to in your expression. When I type in me. void shows up along with all of the other fields in the mastertable. If move the code to report on current, the error goes away but the image always shows. If the code is in Report.Load then I get the 2465 error.

    What am I doing wrong?

    PS Access 2016 64 bit on a windows 10 x64 machine, fully updated.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    put it in the On Print event

    Code:
    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    Me.voided.Visible = Me.Void
    end sub

  3. #3
    dsmithe is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    24
    Private Sub Detail0_Print(Cancel As Integer, PrintCount As Integer)
    Me.voided.Visible = Me.Void
    End Sub

    Error 2465

    Thank you for the suggestion.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    First, remove the 0 from Detail0. Although that isn't cause of this error, it will cause code to fail.

    Both Format and Print events work for me.

    Bind a textbox to the void field. Reports are a bit finicky that way. Not enough that field is in 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.

  5. #5
    dsmithe is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    24
    My detail line is named detail0. I figured a checkbox would be better in my case than a textbox. Once I bound a checkbox to void it worked perfectly. Thank you very much. It even works when the checkbox is hidden.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Did you rename the detail section? I have never changed name of detail section.
    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. Show/Hide Fields based on criteria.
    By jtm013 in forum Queries
    Replies: 6
    Last Post: 08-14-2014, 08:05 AM
  2. Replies: 2
    Last Post: 02-20-2014, 06:51 PM
  3. Show/ hide image based on some field value
    By capitala in forum Reports
    Replies: 4
    Last Post: 04-06-2013, 10:56 AM
  4. Replies: 4
    Last Post: 03-02-2012, 08:41 AM
  5. show / hide columns based on criteria?
    By stevepcne in forum Access
    Replies: 1
    Last Post: 11-18-2011, 02:49 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