Re: Refering to a Reports underlying data using VBA in Detail OnFormat event
- From: "RDub" <rweinerattrcrentdotcom>
- Date: Wed, 2 Sep 2009 13:23:48 -0400
John
Thanks for the suggestion, I decided to go with the 47 invisible check
boxes. It's a nasty hack, but it's all working. I am stuffing strings into
two controls actually. Have just enough room on the report to get 30
strings in two columns. Waiting on the customer to see if 30 is enough.
Might have to go with 3 columns (Label controls). Oye Veh!
Ron W
"John Spencer" <spencer@xxxxxxxxx> wrote in message
news:eIZlcY%23KKHA.4376@xxxxxxxxxxxxxxxxxxxxxxx
If the report does not use a field (bound to a control, used in sorting,
etc.) then when Access builds the query to be used by the report it drops
the field from the source (behind the scenes).
So, you will need to include all those boolean fields on the report or ...
If the record has a primary key you could use a recordset to retreive the
record and step throught the record and build the strings to be printed.
Are you stuffing all the strings into one control?
Dim Dbany as DAO.Database
Dim rst as DAO.Recordset
Dim strSQL as String
strSQL = "SELECT Boolean1, Boolean2, Boolean3 FROM SomeTable Where PK = "
& Me.Pk
Set DbAny = CurrentDb()
Set rst = DbAny.OpenRecordset (strSQL)
'Now process the fields and build the string
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
RDub wrote:
I have a complex report that needs to print a series of strings based on
dozens of Boolean Columns in the table the report is based on (Yea I know
all about data normalization, and I know this is wrong, but this is the
data the customer supplies).
The plan was to use some code in the Detail OnFormat event to determine
which strings need to be printed. However I am unable to refer to any of
the columns in the reports underlying recordset. I get a Error 2465
"ProgramName can't find the field 'afieldname' referred to in your
expression" when I try stuff like: Me!ColumnName or Me("ColumnName"). In
fact I can not even refer to the reports recordset object at all.
Something like Me.Recordset.ColumName will not even compile.
So what's up? It looks like a Reports "Me" reference can only "see"
objects that have been actually created on the report. I would hate to
have to put 4 dozen invisible check boxes on the report just to make this
happen. Aside from fixing the bad table design, does anyone have another
workaround.
Ron W
.
- References:
- Prev by Date: Keep size of subreport the same
- Next by Date: Re: How do I tell an individual field to not break?
- Previous by thread: Re: Refering to a Reports underlying data using VBA in Detail OnFormat event
- Next by thread: Keep size of subreport the same
- Index(es):
Relevant Pages
|