PC Review


Reply
Thread Tools Rate Thread

Changing ControlSource VBA Syntax

 
 
Judy
Guest
Posts: n/a
 
      29th Jan 2006
I'm having difficulty setting the control source of an object on my
report. When I use

Me.Budget.ControlSource = "Budget1"

everything works fine, but I really need to add two fields (or more)
together, so I tried

Me.Budget.ControlSource = "=[Budget1] + [Budget2]"

I believe I have used this syntax before. This time the data on my
report is wrong. Within a group, each line has the same data as the
first line item in the group. Any ideas about what I'm doing wrong?
Thanks.

 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      29th Jan 2006
"Judy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)
> I'm having difficulty setting the control source of an object on my
> report. When I use
>
> Me.Budget.ControlSource = "Budget1"
>
> everything works fine, but I really need to add two fields (or more)
> together, so I tried
>
> Me.Budget.ControlSource = "=[Budget1] + [Budget2]"
>
> I believe I have used this syntax before. This time the data on my
> report is wrong. Within a group, each line has the same data as the
> first line item in the group. Any ideas about what I'm doing wrong?
> Thanks.


In what event are you setting this controlsource? Could you explain
what sort of grouping is going on, and where the text box is in the
grouping sections?

A test worked fine for me in a simple, ungrouped report.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
Judy
Guest
Posts: n/a
 
      29th Jan 2006
Thank you for your reply. It is in the open event of the report. Each
line item of the report is a purchased item. They are grouped first by
project and then by Director.

Something like

Director Smith
Project 1
Item 1
Item 2
Item 3
Project 2
Item 4
Item 5
Director Jones
Project 3
Item 6
Item 7
Project 4
Item 8
Director Fox
etc

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      29th Jan 2006
"Judy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)
> Thank you for your reply. It is in the open event of the report. Each
> line item of the report is a purchased item. They are grouped first
> by project and then by Director.
>
> Something like
>
> Director Smith
> Project 1
> Item 1
> Item 2
> Item 3
> Project 2
> Item 4
> Item 5
> Director Jones
> Project 3
> Item 6
> Item 7
> Project 4
> Item 8
> Director Fox
> etc


I'm not able to reproduce this so far. What version of Access? Would
you care to send me a cut-down copy of the database to look at? If so,
eliminate all but the elements necessary to demonstrate the problem,
compact it, and zip it to less than 1MB in size (preferably much
smaller) -- I'll have a look at it, time permitting. You can send it
to the address derived by removing NO SPAM from the reply address of
this message. If that address isn't visible to you, you can get it from
my web site, which is listed in my sig. Do *not* post my real address
in the newsgroup -- I don't want to be buried in spam and viruses.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
Judy
Guest
Posts: n/a
 
      29th Jan 2006
Thanks for your kind offer. I think I have found a work around for now
(combining them in the query that the report is based on, not very
elegant I realize). I am so grateful for your time. Judy

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      29th Jan 2006
"Judy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)
> Thanks for your kind offer. I think I have found a work around for
> now (combining them in the query that the report is based on, not very
> elegant I realize). I am so grateful for your time. Judy


But then why are you modifying the controlsource at run time in the
first place?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
Judy
Guest
Posts: n/a
 
      30th Jan 2006
Basically, there are six columns on the report. Which six depends on
the user input and the current date. There are 39 fields that need to
be combined in various ways to get the appropriate value for the column.

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      30th Jan 2006
"Judy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)
> Basically, there are six columns on the report. Which six depends on
> the user input and the current date. There are 39 fields that need to
> be combined in various ways to get the appropriate value for the
> column.


Another alternative would be to have text boxes for all possible
combinations, overlaid on the report, but only make those visible that
you want for a particular run. But I don't know why your original code
wasn't working, as I was unable to reproduce the problem. Another thing
to do is make sure that every field you want to use in a calculation
also exists in a bound text box on the report, even if that text box is
invisible. I don't know if this could be the cause of your problem or
not.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
Judy
Guest
Posts: n/a
 
      30th Jan 2006
Lol, that was the way I started out doing it before I decided to learn
VBA. The reports were so difficult to modify and edit with all those
boxes stacked on top of each other. I am also perplexed as to why it
doesn't work, as I have used that sytax in similar situations on other
reports. Could the problem be that the field names have a space?

I will try adding the invisible fields to the report, as per your last
suggestion. Thanks so much for your help.
Judy

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      30th Jan 2006
"Judy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)
> Lol, that was the way I started out doing it before I decided to learn
> VBA. The reports were so difficult to modify and edit with all those
> boxes stacked on top of each other.


True, they would be.

> I am also perplexed as to why it
> doesn't work, as I have used that sytax in similar situations on other
> reports. Could the problem be that the field names have a space?


I don't think so, since you seem to have them properly bracketed.

> I will try adding the invisible fields to the report, as per your last
> suggestion. Thanks so much for your help.


Please let me know if that makes things better.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
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
Syntax to set controlsource of listbox in subform kc-mass Microsoft Access VBA Modules 10 22nd Jun 2009 09:14 PM
Changing ControlSource property on a subform Rod Microsoft Access Form Coding 3 12th Dec 2007 02:16 PM
Syntax for TextBox ControlSource Property to another worksheet =?Utf-8?B?amFtOTY2Mw==?= Microsoft Excel Programming 2 7th Oct 2006 11:45 AM
VBA Syntax for ControlSource Judy Microsoft Access Reports 3 28th Jan 2006 09:31 PM
Changing ControlSource Rick Microsoft Access Forms 0 9th Dec 2003 07:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:20 PM.