By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,510 Members | 1,437 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,510 IT Pros & Developers. It's quick & easy.

Make Line on Report Conditionally Visible?

P: 31
Hey All,

Ive reached another aesthetic stumbling block: I have a report that lists all the widgets on Optimus Prime with the fields "Widget Number" and "ID Number" (and some other fields). Sometimes the widgets get ID numbers, and sometimes they don't; the widgets without ID numbers get the value "n/a"--this value is found in the table/query the report is based upon. What I want to happen is have the ID numbers be underlined if they have a value <> n/ajust to draw attention to them.

So, I made a line ([Line36]) on the report underneath the text box for [ID Number], made it invisible, and in my code I said:
Expand|Select|Wrap|Line Numbers
  1.     If Me.[ID Number] <> "n/a" Then
  2.                Me![Line36].Visible = True
  3.       End If
The result, however, was a report that showed them all underlined; and, if I changed the code to say = n/a, it makes them all invisible. My thought is that Access is seeing that the first record <> n/a (which is always the case) and is applying that to the report all the way down through the remaining records.

Is there a way to make this line conditionally invisible? I guess it could apply to any number of format properties: like, if not n/a make the value BOLD or ITALICIZED, etc.

thanks,

andy
Apr 21 '10 #1

✓ answered by ADezii

The following code, placed in the Report's Detail Section's Print() Event, should do the trick:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
  2.   Me![Line36].Visible = Me![ID Number] <> "n/a"
  3. End Sub

Share this Question
Share on Google+
5 Replies


NeoPa
Expert Mod 15k+
P: 31,186
See Why Values in Unbound Form Controls do not Persist for why it's behaving as it is.

As a replacement you could look into Conditional Formatting. It should suit your purpose.

Welcome to Bytes!
Apr 22 '10 #2

P: 31
Thanks, Pa...This all makes sense; sometimes we ask too much. I'll look into the conditional formatting.
Apr 22 '10 #3

NeoPa
Expert Mod 15k+
P: 31,186
Or, put another way, sometimes we don't (yet) know enough to ask the right questions. Experience always helps.
Apr 22 '10 #4

ADezii
Expert 5K+
P: 8,601
The following code, placed in the Report's Detail Section's Print() Event, should do the trick:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
  2.   Me![Line36].Visible = Me![ID Number] <> "n/a"
  3. End Sub
Apr 23 '10 #5

NeoPa
Expert Mod 15k+
P: 31,186
While I wouldn't recommend ADezii's solution over conditional formatting for your current situation, it is the answer to your original question. Hence I've assigned it as the Best Answer.

It's also very interesting information that will probably help you, and others, handle related issues in future.
Apr 23 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.