Full Version: If Check Box Show Text Box On Report
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
galelynn
I have a report where I want to check a check box and if true I want a text box to show else make it invisible. Below is the code I have on the report On Current event however, it's not working. Would appreciate any suggestions.

check box = mocBill
text box = mocText

Private Sub Report_Current()
If Me.mocBill = Yes Then
Me.mocText.Visible = Yes
Else
Me.mocText.Visible = No
End If
End Sub

Basically if it's a mock bill I want to display a text box saying Mock Billing and if it's not then it will be blank.

Thanks in advance.

MikeLyons
QUOTE (galelynn @ May 30 2012, 11:19 AM) *
I have a report where I want to check a check box and if true I want a text box to show else make it invisible. Below is the code I have on the report On Current event however, it's not working. Would appreciate any suggestions.

check box = mocBill
text box = mocText

Private Sub Report_Current()
If Me.mocBill = Yes Then
Me.mocText.Visible = Yes
Else
Me.mocText.Visible = No
End If
End Sub


Instead of Yes and No, try using True or False, respectively.

If you don't need to do anything else dependent on the value of mocBill, you can shorten the code to one line:

CODE
Me.mocText.Visible = Me.mocBill


Mike
theDBguy
Hi,

welcome2UA.gif

Are you viewing your report in Report View or Print Preview? Did you also want this to happen when you actually print the report?

PS. I moved your topic from Access Queries into the Reports forum.

Just my 2 cents... 2cents.gif
galelynn
I'm viewing in report view but I also want to print it.
galelynn
Thanks Mike. I put the shorter code in and it's working I think but after selecting a new customer and a new month and bringing up a new report, the calculated total and the text box are not there until I click on the report. Is there some kind of command to refresh the screen or something that would force it to display correctly right away?
theDBguy
Hi,

That's interesting... I was thinking that the Current event was the wrong event to use, and I didn't even expect it to do anything.

Just my 2 cents... 2cents.gif
galelynn
It seems to correct itself if I click on the report but I shouldn't have to do that. After your comment I moved it to Load and now I don't have the problem. Thanks so much for both of your help.
theDBguy
Hi,

yw.gif

Glad to hear you got it fixed. Mike and I are happy to assist.

Good luck with your project.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.