How to refer to a field in an Event Procedure?

A

Amit

Windows XP, MS 2K
==================
Hi,

How do I refer to a field while writing code in an Event
Procedure of a report? The field in question is in the
query which is the record source for the report, but is
not being used on the report.

I tried "Me.<fieldName>", but when I run the report, I get
the error message:
"Microsoft Access can't find the field referred to in your
expression."

Here's the code:
===================================================
Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
If IsNull(Me.OrgActivityDescr) Or Len
(Me.OrgActivityDescr) = 0 Then
Me.lblActivityDescrSR.Visible = False
Me.txtActivity.Visible = False
Me.txtActivityCostSR.Visible = False
Else
Me.lblActivityDescrSR.Visible = True
Me.txtActivity.Visible = True
Me.txtActivityCostSR.Visible = True
End If
End Sub
===================================================
I also tried replacing "Me.OrgActivityDescr" with the
following:
"[qName].[OrgActivityDescr]", "[qName.OrgActivityDescr]"
and "[qName]![OrgActivityDescr]" with no success.

Thanks!

-Amit
 
D

Duane Hookom

You must bind the field to a control in the report. It doesn't have to be
visible.
 
A

Amit

Aha!
Thanks for the prompt response.

-Amit
-----Original Message-----
You must bind the field to a control in the report. It doesn't have to be
visible.

--
Duane Hookom
MS Access MVP
--

Windows XP, MS 2K
==================
Hi,

How do I refer to a field while writing code in an Event
Procedure of a report? The field in question is in the
query which is the record source for the report, but is
not being used on the report.

I tried "Me.<fieldName>", but when I run the report, I get
the error message:
"Microsoft Access can't find the field referred to in your
expression."

Here's the code:
===================================================
Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
If IsNull(Me.OrgActivityDescr) Or Len
(Me.OrgActivityDescr) = 0 Then
Me.lblActivityDescrSR.Visible = False
Me.txtActivity.Visible = False
Me.txtActivityCostSR.Visible = False
Else
Me.lblActivityDescrSR.Visible = True
Me.txtActivity.Visible = True
Me.txtActivityCostSR.Visible = True
End If
End Sub
===================================================
I also tried replacing "Me.OrgActivityDescr" with the
following:
"[qName].[OrgActivityDescr]", "[qName.OrgActivityDescr]"
and "[qName]![OrgActivityDescr]" with no success.

Thanks!

-Amit


.
 
Top