473,321 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Setting ControlSource in VBA

Hello,

I am using MS Access 2003 and trying to set a textbox's ControlSource in VBA code.


this following works fine

Task.ControlSource = "[ActivityQuery_Crosstab].[Task]"

However, if i try to set the control source using an expression like:

txtCost.ControlSource = "[ActivityQuery_Crosstab]![Total] * [ActivityQuery_Crosstab]![CostOut]

or

txtCost.ControlSource = "[Total] * [CostOut]"

Access tells me it cannot find the Field.

Am I issing something in the formatting here, I have tried using Expression Builder in a Query and then copy and pasting but no good.

Any ideas please?

regards,

Nick
Feb 9 '10 #1

✓ answered by nico5038

Access tries to "bind" the field to the recordsource.
You need a so-called unbound control and there the controlsource needs to start with a "=" like:
txtCost.ControlSource = "=[Total] * [CostOut]"

Nic;o)

2 21269
nico5038
3,080 Expert 2GB
Access tries to "bind" the field to the recordsource.
You need a so-called unbound control and there the controlsource needs to start with a "=" like:
txtCost.ControlSource = "=[Total] * [CostOut]"

Nic;o)
Feb 9 '10 #2
Many thanks, a simple solution that has saved the rest of my hair!

Nick
Feb 9 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Shelli Carol | last post by:
Good day, I have: 1) A table with numbered fields (1, 2, 3, etc.) 2) A form text box, whose ControlSource property contains an expression. This expression returns a number. If I just...
4
by: Steve Jorgensen | last post by:
Hi all, This is actually not an issue of mine, but one a friend of mine told me about that I was able to confirm. Let's say you want a highly customizable report, so you want to be able to do...
0
by: Paul T. RONG | last post by:
Hello there, there is a text box txt0, its controlsource is =( & ", " & ) it works in one mdb, but not in another. Where is the problem? please help. Paul
6
by: MLH | last post by:
I have a form named frmVehicleEntryForm. It has a 3-tab tab control. On the 2nd tab page, there's a textbox named VehicleLocationName whose default value setting is ...
1
by: Mexar | last post by:
My programming grammar might be a little off but I have a pretty good idea of what I need to convey. I am making an Access database with a form that pops up and lets you choose to select an...
3
by: Michael R | last post by:
Hello. I need a help to solve the following: I'm intersted in having the Control Source of a textbox as following: ="Comment, " & When I input this from Design View into the Control...
2
by: brnkstyle | last post by:
I want to change the controlsource of a textbox when i click a command button but everytime i do so it gives me #Name$ in the text boxt this is what i want to control source to be ...
13
by: ringer | last post by:
Hi, I have a text box on report where I need to have dsum return a total. The records I need the total from are not in the table that is the report's recordsource, and to complicate things...
0
by: =?Utf-8?B?Q2hyaXN0aWFuIEJhaG5zZW4=?= | last post by:
Is it possible to bind a data access page textbox controlsource property at run time? I've tried using the BeforeInitialBind event to set the controlsource for textboxes, using syntax like ...
14
by: OldBirdman | last post by:
I have a textbox on a continuous form that I want to display a calculated value. I have set the ControlSource Property = & "~" & . I would like to have my user be able to correct this value, and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.