PC Review


Reply
Thread Tools Rate Thread

can I use Eval() for report controls ?

 
 
=?Utf-8?B?bXNjZXJ0aWZpZWQ=?=
Guest
Posts: n/a
 
      10th Aug 2005
I have a report with 50 columns whch must have their background colors set
based on values in an input table. Can I use Eval within a loop to do this?
All attempts so far have failed. Or is there another way to loop thru the
controls in a report section?
 
Reply With Quote
 
 
 
 
Duane Hookom
Guest
Posts: n/a
 
      10th Aug 2005
What are you attempting to do? You can loop through the controls collection
of a report fairly easily.

Dim ctl as Control
For each ctl in Me.Controls
'some code
Next

--
Duane Hookom
MS Access MVP
--

"mscertified" <(E-Mail Removed)> wrote in message
news:AED738FF-1F94-4B77-AEC2-(E-Mail Removed)...
>I have a report with 50 columns whch must have their background colors set
> based on values in an input table. Can I use Eval within a loop to do
> this?
> All attempts so far have failed. Or is there another way to loop thru the
> controls in a report section?



 
Reply With Quote
 
=?Utf-8?B?bXNjZXJ0aWZpZWQ=?=
Guest
Posts: n/a
 
      10th Aug 2005
I have heading controls H1 thru H50 in my page header and I need to
programatically set the values where H1 is the number of the current month,
then incrementing from there eg 8,9,10,11,12,1,2,3 etc.
I'm using your method to get the control names but how do I set the value. I
tried
ctl =
ctl.value =
Eval(ctl.name) =

nothing seems to work.....

The other thing I need to do is to dynamically set the background colors of
each of 50 columns (named M1 thru M50) in the detail section based on numeric
values in my source table. E.g. M1=1 make background purple, M1=2 make
background red etc. etc. The colors will vary from column to column and row
to row. I hope I don't have to use conditional formatting for this as I need
more than 5 variations.

any advice most appreciated

David

"Duane Hookom" wrote:

> What are you attempting to do? You can loop through the controls collection
> of a report fairly easily.
>
> Dim ctl as Control
> For each ctl in Me.Controls
> 'some code
> Next
>
> --
> Duane Hookom
> MS Access MVP
> --
>
> "mscertified" <(E-Mail Removed)> wrote in message
> news:AED738FF-1F94-4B77-AEC2-(E-Mail Removed)...
> >I have a report with 50 columns whch must have their background colors set
> > based on values in an input table. Can I use Eval within a loop to do
> > this?
> > All attempts so far have failed. Or is there another way to loop thru the
> > controls in a report section?

>
>
>

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      10th Aug 2005
mscertified wrote:

>I have a report with 50 columns whch must have their background colors set
>based on values in an input table. Can I use Eval within a loop to do this?
>All attempts so far have failed. Or is there another way to loop thru the
>controls in a report section?



No. Eval is intended for a different purpose.

If your controls are named with a common prefix and a
numeric suffix, you can reference the controls using the
alternate syntax:

Me("prefix" & number)

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
Duane Hookom
Guest
Posts: n/a
 
      10th Aug 2005
Since your heading controls are numbered, you should be able to set values
like:

Dim intCnt as Integer
For intCnt = 1 to 50
Me("H" & intCnt) = ...some value expression...
Next

This assumes your controls are unbound text boxes.

I think you might be making this harder than need be but you haven't really
provided much background.

--
Duane Hookom
MS Access MVP
--

"mscertified" <(E-Mail Removed)> wrote in message
news9F4CEE2-5907-4C30-A07C-(E-Mail Removed)...
>I have heading controls H1 thru H50 in my page header and I need to
> programatically set the values where H1 is the number of the current
> month,
> then incrementing from there eg 8,9,10,11,12,1,2,3 etc.
> I'm using your method to get the control names but how do I set the value.
> I
> tried
> ctl =
> ctl.value =
> Eval(ctl.name) =
>
> nothing seems to work.....
>
> The other thing I need to do is to dynamically set the background colors
> of
> each of 50 columns (named M1 thru M50) in the detail section based on
> numeric
> values in my source table. E.g. M1=1 make background purple, M1=2 make
> background red etc. etc. The colors will vary from column to column and
> row
> to row. I hope I don't have to use conditional formatting for this as I
> need
> more than 5 variations.
>
> any advice most appreciated
>
> David
>
> "Duane Hookom" wrote:
>
>> What are you attempting to do? You can loop through the controls
>> collection
>> of a report fairly easily.
>>
>> Dim ctl as Control
>> For each ctl in Me.Controls
>> 'some code
>> Next
>>
>> --
>> Duane Hookom
>> MS Access MVP
>> --
>>
>> "mscertified" <(E-Mail Removed)> wrote in message
>> news:AED738FF-1F94-4B77-AEC2-(E-Mail Removed)...
>> >I have a report with 50 columns whch must have their background colors
>> >set
>> > based on values in an input table. Can I use Eval within a loop to do
>> > this?
>> > All attempts so far have failed. Or is there another way to loop thru
>> > the
>> > controls in a report section?

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?bXNjZXJ0aWZpZWQ=?=
Guest
Posts: n/a
 
      10th Aug 2005
My 1600 page Access book does not mention this syntax, but I'll give it a try.
Can I set control properties that way too, e.g. Background color?

David

"Marshall Barton" wrote:

> mscertified wrote:
>
> >I have a report with 50 columns whch must have their background colors set
> >based on values in an input table. Can I use Eval within a loop to do this?
> >All attempts so far have failed. Or is there another way to loop thru the
> >controls in a report section?

>
>
> No. Eval is intended for a different purpose.
>
> If your controls are named with a common prefix and a
> numeric suffix, you can reference the controls using the
> alternate syntax:
>
> Me("prefix" & number)
>
> --
> Marsh
> MVP [MS Access]
>

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      11th Aug 2005
Yes, you can reference an element of any collection using
that syntax (see Collection and Item in Help).

The Properties collection is no different. e.g.
strPName = "BackColor"
Me.sometextbox.Properties(strPName) = somevalue

The reason you do not need to specify the Controls
collection when you use Me(strControlName) is that Controls
is the default collection for a form object. The full
rigorous syntax is:
Me.Controls(strControlName)
well, actually it's
Me.Controls.Item(strControlName)
but hardly anyone explicitly uses the Item property.
--
Marsh
MVP [MS Access]



mscertified wrote:
>My 1600 page Access book does not mention this syntax, but I'll give it a try.
>Can I set control properties that way too, e.g. Background color?
>
>
>> mscertified wrote:
>> >I have a report with 50 columns whch must have their background colors set
>> >based on values in an input table. Can I use Eval within a loop to do this?
>> >All attempts so far have failed. Or is there another way to loop thru the
>> >controls in a report section?

>>
>>

>"Marshall Barton" wrote:
>> No. Eval is intended for a different purpose.
>>
>> If your controls are named with a common prefix and a
>> numeric suffix, you can reference the controls using the
>> alternate syntax:
>>
>> Me("prefix" & number)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using in "Eval" in databound controls Newish Microsoft ASP .NET 1 28th Sep 2006 10:19 AM
ANN: OpenNETCF Calendar Controls Eval available Microsoft Dot NET Compact Framework 0 30th Jun 2006 12:34 AM
How to stop report controls moving when controls above grow Sam D Microsoft Access Reports 1 20th Apr 2004 11:34 AM
SavePart ... a first-hand & detailed eval report Chief Suspect Freeware 9 15th Feb 2004 11:18 PM
Using SBS eval copy, ordered full version today, possible to use CD KEY w/eval copy? =?Utf-8?B?Y3ZlbHVzYw==?= Microsoft Windows 2000 0 2nd Dec 2003 08:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:39 PM.