How reference data from a report in code?

L

Laurel

I would like to put the following code somewhere in a report.

If <the data in the current record from tblPrimary.person_id> is null then
lblPrimary.visible = false
End if

Is this possible? Will the current event keep the label and the data for a
single record together?

How do I reference the data (the part in angle brackets)

TIA
LAS
 
F

fredg

I would like to put the following code somewhere in a report.

If <the data in the current record from tblPrimary.person_id> is null then
lblPrimary.visible = false
End if

Is this possible? Will the current event keep the label and the data for a
single record together?

How do I reference the data (the part in angle brackets)

TIA
LAS

Code the Detail Section's Format event:

Me.[lblPrimaryVisible] = Not IsNull(Me.[Person-id])
 
L

Laurel

Thanks!
fredg said:
I would like to put the following code somewhere in a report.

If <the data in the current record from tblPrimary.person_id> is null
then
lblPrimary.visible = false
End if

Is this possible? Will the current event keep the label and the data for
a
single record together?

How do I reference the data (the part in angle brackets)

TIA
LAS

Code the Detail Section's Format event:

Me.[lblPrimaryVisible] = Not IsNull(Me.[Person-id])
 
L

Laurel

Well, the code I put in was acceptable, but it never triggers. What event
would I put it in? I put it in the Report Current event. But apparently
that's not the right one.

fredg said:
I would like to put the following code somewhere in a report.

If <the data in the current record from tblPrimary.person_id> is null
then
lblPrimary.visible = false
End if

Is this possible? Will the current event keep the label and the data for
a
single record together?

How do I reference the data (the part in angle brackets)

TIA
LAS

Code the Detail Section's Format event:

Me.[lblPrimaryVisible] = Not IsNull(Me.[Person-id])
 
F

fredg

Well, the code I put in was acceptable, but it never triggers. What event
would I put it in? I put it in the Report Current event. But apparently
that's not the right one.

fredg said:
I would like to put the following code somewhere in a report.

If <the data in the current record from tblPrimary.person_id> is null
then
lblPrimary.visible = false
End if

Is this possible? Will the current event keep the label and the data for
a
single record together?

How do I reference the data (the part in angle brackets)

TIA
LAS

Code the Detail Section's Format event:

Me.[lblPrimaryVisible] = Not IsNull(Me.[Person-id])

A report does not have a current event.
Each Report Section has a Format and a Print event (i.e. the Detail
Section Format event).
You have posted this question in a Forms Newsgroup, perhaps you meant
a form. If that is so, please re-think and clarify your question so
that we can know what it is you are trying to do.
 
A

Arvin Meyer MVP

If you use "stuck", or "associated" labels, that is unnecessary. If the
textbox is not visible, the label won't be. Simply cut the label, then
select the textbox and paste, and the label will associate with that text
box.

To answer your question specifically, yes you can do it this way:

1. Create an [Event Procedure] in the report section's Format event, and use
code similar to:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Len(Me.Person_Id & vbNullString) = 0 Then
Me.lblPrimary.visible = false
End If
End Sub
 
L

Laurel

Ah. I wasn't thinking about the differences between forms and reports.
It's really a report. But there IS a "current" event in the code work area.
It sounds like I need to turn this into a form so that there is an event
that triggers for each new record. True?


fredg said:
Well, the code I put in was acceptable, but it never triggers. What
event
would I put it in? I put it in the Report Current event. But apparently
that's not the right one.

fredg said:
On Fri, 3 Jul 2009 18:09:50 -0400, Laurel wrote:

I would like to put the following code somewhere in a report.

If <the data in the current record from tblPrimary.person_id> is null
then
lblPrimary.visible = false
End if

Is this possible? Will the current event keep the label and the data
for
a
single record together?

How do I reference the data (the part in angle brackets)

TIA
LAS

Code the Detail Section's Format event:

Me.[lblPrimaryVisible] = Not IsNull(Me.[Person-id])

A report does not have a current event.
Each Report Section has a Format and a Print event (i.e. the Detail
Section Format event).
You have posted this question in a Forms Newsgroup, perhaps you meant
a form. If that is so, please re-think and clarify your question so
that we can know what it is you are trying to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top