Visible not working (1 Viewer)

AceBK

Registered User.
Local time
Yesterday, 23:19
Joined
Dec 2, 2011
Messages
75
I am working on an order form for production. The Docket allows you to add multiple lines for the order and perhaps the Sales rep would like some pictures taken of some of the items but not all of them. I put in a list box with "Yes" or "No" on the form. On the report I have put a picture of a camera 'picofcamera'. In my Report 'on load' code I wrote:

Private Sub Report_Load()
If PictureProof = "Yes" Then
Picofcamera.Visible = True
Else
Picofcamera.Visible = False
End If
End Sub

But for some reason this is not working. Please help? I have put "me." in front of each item, that did not help either. What am I missing?
 

pr2-eugin

Super Moderator
Local time
Today, 05:19
Joined
Nov 30, 2011
Messages
8,494
What is the Data Type of the Column PictureProof in the table? If it is Yes/No then change the "Yes" to True.. Or even..
Code:
Private Sub Report_Load()
    Me.Picofcamera.Visible = Me.PictureProof
End Sub
 

AceBK

Registered User.
Local time
Yesterday, 23:19
Joined
Dec 2, 2011
Messages
75
PR2

I originally put a YES/NO box in there, but I couldn't get it to work, so I changed it to a list box with two options, "YES" or "No" so I could look for text. When I had the check box in place I tried the code that you recommended, but that didn't work either.
AceBK
 

David R

I know a few things...
Local time
Yesterday, 23:19
Joined
Oct 23, 2001
Messages
2,633
Picofcamera isn't on a subform, is it?
 

AceBK

Registered User.
Local time
Yesterday, 23:19
Joined
Dec 2, 2011
Messages
75
Actually it is, but while I am testing it, I am using it in the "Mother" form. not as a sub form. Does that make sense? Let me try to explain it differently. I have a form called "Apparel Docket" and it lists the different items. I put apparel Docket as a subform on a report called "Apparel Docket with Header". So when I test this code I use "Apparel Docket", not "Apparel Docket with Header".
 

David R

I know a few things...
Local time
Yesterday, 23:19
Joined
Oct 23, 2001
Messages
2,633
Referring to a field in a subform is always trickier. I would use the Build button [...] to get a direct reference to the field, because even after ten years I can't always remember what should be a . and what should be a !.

However it is PROBABLY something like
Code:
If Forms.[Apparel Docket with Header].[Apparel Docket].Form.[Picofcamera].Visible = "YES" Then
 

AceBK

Registered User.
Local time
Yesterday, 23:19
Joined
Dec 2, 2011
Messages
75
I don't think I explained it right. I have a table 'Order Form' of which I have forms made from. The form I am using to gather the info for this is "Apparel Order Form". I have a Report named "Apparel Docket with Header", which gathers info from a query based on a different Table "Jobs List", to create my header, then I have a subreport "Apparel Docket" which lists the items gathered from the Table "Order Form". The picture of the camera is put right on the Report "Apparel Docket". If PictureProof is "Yes" - recorded in Table "Order Form", I would like picofcamera to appear, if it is "No", I would like the picture of the camera to not appear.
 

David R

I know a few things...
Local time
Yesterday, 23:19
Joined
Oct 23, 2001
Messages
2,633
Did you try the Build button to find a reference to the picture? What did it give you? Try posting your revised load() sub.
 

AceBK

Registered User.
Local time
Yesterday, 23:19
Joined
Dec 2, 2011
Messages
75
When I right click on the picture, the "Build" is greyed out, I can only "Build Event". I don't have a revised Load()Sub, it hasn't really changed yet.
 

AceBK

Registered User.
Local time
Yesterday, 23:19
Joined
Dec 2, 2011
Messages
75
I think we are going in the wrong direction, but I could be wrong. I have a report based on a query. The query reads the value of 'PictureProof' as being "Yes". So when I run my report from this query, the PictureProof for two of the three lines is "YES". Based on that, I want the picofcamera to appear on the report on two of the three lines. I don't believe this is related to Forms or subforms. The picture was put straight onto the report and the listbox "PictureProof" was put in the table called "Order Forms"
 

David R

I know a few things...
Local time
Yesterday, 23:19
Joined
Oct 23, 2001
Messages
2,633
Form/subform is basically the same syntax as report/subreport, though. Have you tried using the Build button ([...]) to find how to call PictureProof directly on the report?

You're right that sometimes that Build button is greyed out. An almost infalliable place to get it is the RecordSource field... you can use that to get to the Build screen, even though you're ACTUALLY going to use the string in VBA or whatever.
 

AceBK

Registered User.
Local time
Yesterday, 23:19
Joined
Dec 2, 2011
Messages
75
I am not sure I know what you mean. PictureProof is in the query in which the report is based on, so it is directly on the report already. I am not sure what Build would show me. Also, there is no record source field only Control Source, which is PictureProof. As pictureproof is a list box, I thought maybe instead of "Yes" to try 1, but that did not work either. I am so confused. I am wondering if I am doing it right but it is just not working. It seems that the value of PictureProof is not registering in my VBA code.
 

David R

I know a few things...
Local time
Yesterday, 23:19
Joined
Oct 23, 2001
Messages
2,633
Okay, two more things to try, short of uploading a stripped-down copy of your database:

  1. Open your report. Just leave it open in the background, then go open a form or report or anything BOUND in Design Mode. Go to the Properties > Data > Control Source (sorry, not RecordSource) and click the Build wizard. The little box that pops up will have an option for 'loaded Reports' which will make it easier to find your report, and the exact name/reference to PictureProof. Copy that exact reference to your clipboard. Compare that reference to your VBA reference.
  2. If that doesn't provide an immediate answer as to why your code isn't working, put a breakpoint in your Report code somewhere. It doesn't really matter much where, as long as it's something that will always run: Report_Load, or Report_Format, something like that. Now run your report, and in the VBA immediate window at the bottom of the screen, type in:
    Code:
    ? Report!ExactReference!PictureProof.Visible
    If it errors, you know there is something still wrong with the reference. If it gives True or False, you're close and something else is goofy with your VBA.
 

AceBK

Registered User.
Local time
Yesterday, 23:19
Joined
Dec 2, 2011
Messages
75
I have uploaded a very "Dummy" version of what I am trying to do. It didn't work here either so I am hoping you can see my issue and help me with it.
 

David R

I know a few things...
Local time
Yesterday, 23:19
Joined
Oct 23, 2001
Messages
2,633
Errr, where did you upload it?
 

AceBK

Registered User.
Local time
Yesterday, 23:19
Joined
Dec 2, 2011
Messages
75
It did not attach the first time, hopefully it works now.
 

Attachments

  • VisibleTest.accdb
    1.2 MB · Views: 100

David R

I know a few things...
Local time
Yesterday, 23:19
Joined
Oct 23, 2001
Messages
2,633
There was no VBA code at all in your upload... but here's what you need to do:

Click on the Detail Header in report design view, then in Properties > Events > On Format, click the Build button and pick Event Procedure. Make it look like this:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.Image11.Visible = Me.Addphoto
End Sub
with the correct field names, etc for your real database. Save, close, run the report again. Remember that this will only work in Print Preview mode, not Report View!
 

AceBK

Registered User.
Local time
Yesterday, 23:19
Joined
Dec 2, 2011
Messages
75
Does it matter if "AddPhoto" has the property of True/False or Yes/No?
 

David R

I know a few things...
Local time
Yesterday, 23:19
Joined
Oct 23, 2001
Messages
2,633
Nope, those are just display options. The value in the table is always -1 or 0.
 

Users who are viewing this thread

Top Bottom