Solved Equivalent of .visible for textboxes (1 Viewer)

Kayleigh

Member
Local time
Today, 10:27
Joined
Sep 24, 2020
Messages
706
Hi,
Have not worked much with reports but would imagine the VBA to be quite similar to that of forms?
I am attempting to display certain controls based on a field value so my code was something like:

Select case Me.trade
Case 1
Me.fldNotes.visible = true
Case 2
Me.fldDescription.visible = true
End select

I did not see the .visible property as an option when typing the VBA so it looks like this would not work. Can anyone suggest a work-around for this?
 

bob fitz

AWF VIP
Local time
Today, 10:27
Joined
May 23, 2011
Messages
4,717
Are "fldNotes" and "fldDescription" both names of textbox controls on the report?
In which event are you trying to run your code?
 

Kayleigh

Member
Local time
Today, 10:27
Joined
Sep 24, 2020
Messages
706
Yes its in the current event
 

bob fitz

AWF VIP
Local time
Today, 10:27
Joined
May 23, 2011
Messages
4,717
You could try it in the "On Format" event of whichever report section holds the textboxes (I'd guess that would be the Detail Section)
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:27
Joined
May 7, 2009
Messages
19,169
note that the report must be in PrintPreview for the Format event to take effect.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:27
Joined
Feb 28, 2001
Messages
26,996
Review the article below. The section on reports is at the bottom of the article though a couple of hyperlinks in the top of the article would help you find your way to the right part.


Note that event behavior IS different for Print Preview vs. Report View. Certain events occur in Print Preview that DO NOT occur for Report View.

Also remember that there are overall events for the report object, but the ones that you can use for specific appearance issues are for SECTIONS, not for the report as a whole.
 

Kayleigh

Member
Local time
Today, 10:27
Joined
Sep 24, 2020
Messages
706
I didn't get very far - followed your advice but code doesn't compile. Apparently the .visible is not recognised in reports??
What would the equivalent be?
 

Attachments

  • visible error.png
    visible error.png
    274.8 KB · Views: 276

Kayleigh

Member
Local time
Today, 10:27
Joined
Sep 24, 2020
Messages
706
Sorry I take back my words there!
I had named the textbox a different name to controlsource. Now code compiles and works as required.
 
Last edited:

bob fitz

AWF VIP
Local time
Today, 10:27
Joined
May 23, 2011
Messages
4,717
Sorry I take back my words there!
I had named the textbox a different name to controlsource. Now code compiles and works as required.
I'm glad you have an acceptable solution ;)
 

isladogs

MVP / VIP
Local time
Today, 10:27
Joined
Jan 14, 2017
Messages
18,186
For info, you can also use the Display When property which has options Print Only, Screen Only or Always (default value)
 

Users who are viewing this thread

Top Bottom