UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Show/hide Image Control On Continuous Report, Access 2013    
 
   
goakenton
post Nov 3 2019, 07:02 PM
Post#1



Posts: 68
Joined: 20-December 12



Hi, seems like this should be really easy but I've been struggling too long with it. Maybe someone can tell me what I'm getting wrong?

Context
-Main form shows Members (i.e., people)
-A subreport ("subrptMemberInvoiceList") that's on this form shows all Invoices associated with the selected member.
-You choose a member, and it shows you any associated invoices.

What I'm trying to do
-For each invoice record shown on the subreport, I want to show or hide a small padlock image ("imgPadlock") based on the the value of the field "InvoiceLocked" (boolean).
-If InvoiceLocked = TRUE, show the image.
-If InvoiceLocked = FALSE, hide the image. Seems simple.

What I tried
-For testing, I have 4 invoice records for a particular member. Two invoice records have InvoiceLocked = TRUE, and two have InvoiceLocked = FALSE.
-I put the following in the subreport's OnCurrent event:

CODE
Private Sub Report_Current()
If (Me.InvoiceLocked = -1) Then
    Me.imgPadlock.Visible = True
Else
    Me.imgPadlock.Visible = False
End If
End Sub

Result
-On load, the padlock image displays for all records (irrespective of the value of InvoiceLocked)
-If I click on the record where I know InvoiceLocked is FALSE, all 4 images disappear.
-If I click on a record where I know InvoiceLocked is TRUE, all 4 images appear.

Is there a more appropriate event I should be using that would allow the image to display for some records but not others?
Go to the top of the page
 
June7
post Nov 3 2019, 07:30 PM
Post#2



Posts: 1,030
Joined: 25-January 16



That's because programmatically setting properties of a control affects all instances of control on a form. This is the case for any control, not just Image. Programmatic conditional display per record can be done on report.


This post has been edited by June7: Nov 3 2019, 07:32 PM

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! http://www.cpearson.com/Excel/DebuggingVBA.aspx
Go to the top of the page
 
RJD
post Nov 3 2019, 09:21 PM
Post#3


UtterAccess VIP
Posts: 10,153
Joined: 25-October 10
From: Gulf South USA


Hi: This can also be done using a padlock font symbol from, say, Segoe UI Symbol font, and an IIf statement.

See the demo attached. This shows this approach in a form, but it can also be done in a report as well.

Just another idea ...

HTH
Joe
Attached File(s)
Attached File  PadlockTest.zip ( 21.66K )Number of downloads: 13
 

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
goakenton
post Nov 3 2019, 11:16 PM
Post#4



Posts: 68
Joined: 20-December 12



Joe, I love that solution!! Thank you smile.gif
Go to the top of the page
 
RJD
post Nov 3 2019, 11:46 PM
Post#5


UtterAccess VIP
Posts: 10,153
Joined: 25-October 10
From: Gulf South USA


You are very welcome. We are all happy to assist.

Continued success ...

Regards,
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
June7
post Nov 4 2019, 01:33 AM
Post#6



Posts: 1,030
Joined: 25-January 16



I just realized you said you have a subreport on a form. Is that correct?

Adjustment to my earlier comment: report has to be to Print or PrintPreview for programmatic conditional display of controls.

Glad you found a solution.

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! http://www.cpearson.com/Excel/DebuggingVBA.aspx
Go to the top of the page
 
goakenton
post Nov 8 2019, 03:49 PM
Post#7



Posts: 68
Joined: 20-December 12



June7, that's really good to know! Thanks!
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    12th December 2019 - 09:35 PM