Solved Equivalent of .visible for textboxes (1 Viewer)

Krayna

Member
Local time
Today, 17:11
Joined
Sep 24, 2020
Messages
486
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, 17:11
Joined
May 23, 2011
Messages
4,295
Are "fldNotes" and "fldDescription" both names of textbox controls on the report?
In which event are you trying to run your code?
 

Krayna

Member
Local time
Today, 17:11
Joined
Sep 24, 2020
Messages
486
Yes its in the current event
 

bob fitz

AWF VIP
Local time
Today, 17:11
Joined
May 23, 2011
Messages
4,295
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
Tomorrow, 00:11
Joined
May 7, 2009
Messages
14,176
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, 11:11
Joined
Feb 28, 2001
Messages
20,882
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.
 

Krayna

Member
Local time
Today, 17:11
Joined
Sep 24, 2020
Messages
486
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: 88

Krayna

Member
Local time
Today, 17:11
Joined
Sep 24, 2020
Messages
486
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, 17:11
Joined
May 23, 2011
Messages
4,295
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

CID VIP
Local time
Today, 17:11
Joined
Jan 14, 2017
Messages
15,418
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