473,320 Members | 1,936 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,320 software developers and data experts.

How to input text with the control name into ControlSource from VBA?

176 100+
Hello.

I need a help to solve the following:

I'm intersted in having the Control Source of a textbox as following:
="Comment, " & [controlname]

When I input this from Design View into the Control Source, it works.

When I write in VBA:
Expand|Select|Wrap|Line Numbers
  1. Me.txbTextBox.ControlSource = "Comments, " & [Name]
or
Expand|Select|Wrap|Line Numbers
  1. Me.txbTextBox.ControlSource = ""Comments, " & [Name]"
Access returns the #Name? error in Form View.

Any Ideas?

Thanks for your time, Michael.
Dec 5 '06 #1
3 2956
MMcCarthy
14,534 Expert Mod 8TB
Try this

Expand|Select|Wrap|Line Numbers
  1. Me.txbTextBox.ControlSource = "='Comments, ' & [Name]"
  2.  
Hello.

I need a help to solve the following:

I'm intersted in having the Control Source of a textbox as following:
="Comment, " & [controlname]

When I input this from Design View into the Control Source, it works.

When I write in VBA:
Expand|Select|Wrap|Line Numbers
  1. Me.txbTextBox.ControlSource = "Comments, " & [Name]
or
Expand|Select|Wrap|Line Numbers
  1. Me.txbTextBox.ControlSource = ""Comments, " & [Name]"
Access returns the #Name? error in Form View.

Any Ideas?

Thanks for your time, Michael.
Dec 5 '06 #2
Michael R
176 100+
Try this

Expand|Select|Wrap|Line Numbers
  1. Me.txbTextBox.ControlSource = "='Comments, ' & [Name]"
  2.  
Yes, it works!
A pretty peculiar way of syntax to the unexperinced user of VBA as myself, or - "how should I've known this?!".
:)
Thanks.
Dec 5 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
Yes, it works!
A pretty peculiar way of syntax to the unexperinced user of VBA as myself, or - "how should I've known this?!".
:)
Thanks.
Rule is when you're passing a value as a string that contains a string the contained string has to be in single quotes or the engine views each quote as the beginning or end of a string.

The engine probably would put in the = sign but it's better to add it to be sure.

You learn something new every day. :)

Mary
Dec 5 '06 #4

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

Similar topics

2
by: Gwin | last post by:
I am programming a client service dbase in access 2000 for a non-profit health clinic. I want to create a navigation menu that can show varying numbers of command buttons with varying captions,...
7
by: Rab | last post by:
hi i need to programmatically change the caption of a label that is linked to another control (i.e. textbox, combobox). it's for a generic function where i only know the textbox/combobox name...
5
by: Don Sealer | last post by:
I'd like to have a name show up on a report. I have a report based on a query. When the report is activated it asks for a name. I input the name and the query sorts the data and displays it in...
6
by: eclypz | last post by:
Whe i use a combobox, and i want it to update it's value i use the code ME.cbxname.Requery How can i do that to update the value of a textbox? i have already try to use the same expression,...
2
by: SueA | last post by:
Can anyone help me with the code to retrieve the name of the table that a control on a form (that's built off a query) refers to? For instance: qryMfrsAndBrands is based on the tables:...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
5
by: vsteshenko | last post by:
Hello, This is my second post to the any usernet group and the first one was posted to the wrong one. I am currently working on creating an order form for sales associates at my work to be used...
4
by: pradeep | last post by:
how to set input type label's value through javascript
9
by: RICHARD BROMBERG | last post by:
I am using Access 2000 and I would like to make a data entry form (frmDataEntry) I want to append a newrecord to a table (tblPeople) and populate the new record from two Textboxes (txtName 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...
1
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.