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

Very small bitmap graphic as picture object on report - how to set visible property on Format event?

P: n/a
MLH
I have a small bitmap graphic on a report.
I would like to set it's Visible property to True
whe the value of a certain field on the report
is True. Can I do that? I have tried in the
OnFormat event code...

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me!ThreeBucks = True Then Me!ThreeDollarRansomNote.Visible = True
Else Me!ThreeDollarRansomNote.Visible = False

End Sub
(watch out for word-wrap)

But that fails. Suggestions?
Jan 7 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
You must put this in the OnFormat of the Detail section of the report:

Private Sub Detail_Format(cancel As Integer, FormatCount As Integer)
On Error GoTo myErr

'>set icon:
If Len(Me!myDataName) 0 Then
Me.ImageName.Visible = True
Else
Me.ImageName.Visible = False
End If

myExit:
Exit Sub
myErr:
MsgBox Err.Number & "-" & Err.Description
Resume myExit
End Sub
Jan 7 '08 #2

P: n/a
On Mon, 07 Jan 2008 16:29:59 -0500, MLH wrote:
I have a small bitmap graphic on a report.
I would like to set it's Visible property to True
whe the value of a certain field on the report
is True. Can I do that? I have tried in the
OnFormat event code...

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me!ThreeBucks = True Then Me!ThreeDollarRansomNote.Visible = True
Else Me!ThreeDollarRansomNote.Visible = False

End Sub
(watch out for word-wrap)

But that fails. Suggestions?
At the very least you are missing an End If.

Try it this way.

Assuming ThreeRansomNote is the name of the Image Control, and
ThreeBucks is the name of your True/False control (and it is a Boolean
control not text) .....

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me!ThreeDollarRansomNote.Visible = Me!ThreeBucks
End Sub
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jan 8 '08 #3

P: n/a
MLH
I tried it again - this time I made sure the query upon
which the report was based returned some records.
It worked then. Your suggestion looks like it too
would work.

I'm a bit surprised at the error I was getting being a
2427 error: "You entered an expression that has no
value". If the report object's recordsource produces
no records, the Format event is still occuring. The
OnFormat code is running - that's what's producing
the error. But what's so wrong with the expression
that this error occurs when no records are returned?

Even if I change the problem line to read...

If Nz(Me!ThreeBucks, 0) = True Then Me!ThreeDollarRansomNote.Visible =
True Else Me!ThreeDollarRansomNote.Visible = False

.... I still get the same error! What's with that? So what?
The value in the damned textbox ain't True, it ain't False
and it apparently ain't Null either. Otherwise - why would
Access report this error?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Mon, 7 Jan 2008 14:39:16 -0800 (PST), Lauren Quantrell
<la*************@hotmail.comwrote:
>You must put this in the OnFormat of the Detail section of the report:

Private Sub Detail_Format(cancel As Integer, FormatCount As Integer)
On Error GoTo myErr

'>set icon:
If Len(Me!myDataName) 0 Then
Me.ImageName.Visible = True
Else
Me.ImageName.Visible = False
End If

myExit:
Exit Sub
myErr:
MsgBox Err.Number & "-" & Err.Description
Resume myExit
End Sub
Jan 8 '08 #4

P: n/a
MLH
Naw. That's not it. The 'word wrap' confused you. The if-then-else
is all on 1 line. That compiles fine. The error returned is a 2427
that I experienced when the RecordSource query returned NO
records. When it returns records, the small graphic displays on
some pages and not others - exactly as intended. The error has
me baffled. I'm getting it in A97. But it may be the case in advanced
versions as well, dunno.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Mon, 7 Jan 2008 16:24:47 -0800, fredg <fg******@example.invalid>
wrote:
>On Mon, 07 Jan 2008 16:29:59 -0500, MLH wrote:
>I have a small bitmap graphic on a report.
I would like to set it's Visible property to True
whe the value of a certain field on the report
is True. Can I do that? I have tried in the
OnFormat event code...

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me!ThreeBucks = True Then Me!ThreeDollarRansomNote.Visible = True
Else Me!ThreeDollarRansomNote.Visible = False

End Sub
(watch out for word-wrap)

But that fails. Suggestions?

At the very least you are missing an End If.

Try it this way.

Assuming ThreeRansomNote is the name of the Image Control, and
ThreeBucks is the name of your True/False control (and it is a Boolean
control not text) .....

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me!ThreeDollarRansomNote.Visible = Me!ThreeBucks
End Sub
Jan 8 '08 #5

P: n/a
On Jan 7, 9:29*pm, MLH <C...@NorthState.netwrote:
I have a small bitmap graphic on a report.
I would like to set it's Visible property to True
whe the value of a certain field on the report
is True. Can I do that? I have tried in the
OnFormat event code...

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me!ThreeBucks = True Then Me!ThreeDollarRansomNote.Visible = True
Else Me!ThreeDollarRansomNote.Visible = False

End Sub
(watch out for word-wrap)

But that fails. Suggestions?
How about
Me!ThreeDollarRansomNote.Visible = me!ThreeBucks

Looks simpler. Does the same job

Jim
Jan 8 '08 #6

P: n/a
MLH
<snip>
I like that!
Thanks.
>
How about
Me!ThreeDollarRansomNote.Visible = me!ThreeBucks

Looks simpler. Does the same job

Jim
Jan 10 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.