text field = multiple other fields

  • Thread starter Thread starter The Boondock Saint
  • Start date Start date
T

The Boondock Saint

Is there a way you can have a text field = other fields

something like

texta = Rabbits
textb = Cows

text1 = "[texta] "are faster than" [textb]"
so that it shows
text1 = Rabbits are faster than Cows

Using Office 2000

Thanks for your help,
The Saint
 
Hi Saint

Yes, you do this with a calculated field (or calculated control). Basically,
what this means is that the value in the field (or control) is calculated
from an expression involving other data. This could be a simple arithmetic
or string expression or something more complex.

You create a calculated field in a query and a calculated control in a form.

In a query, add the table(s) containing the fields you require, then add the
fields to the query grid. To make the calculated field, enter in a blank
field cell:
FieldName: Expression
(for example)
SpeedStatement: [texta] & " are faster than " & [textb]

Note that the & sign joins strings together, just like the + sign adds
numbers. This expression joins three strings. The middle one is called a
"literal string". Note that it is enclosed in quotes and also that it
includes spaces at either end (otherwise you would get "Rabbitsare faster
thanCows").

You can then bind your query to a form or report and use the field named
"SpeedStatement" just as you would use another field (except that it's not
editable).

You can also do the calculation directly in a form or report. Bind the
form/report to your table and add a textbox to it with the ControlSource:
=[texta] & " are faster than " & [textb]
 
Hi Boondock,

Assuming texta, textb and text1 are text boxes on the same form, use this as
the control source for the text1 textbox:

=[texta] & " are faster than " & [textb]


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

Is there a way you can have a text field = other fields

something like

texta = Rabbits
textb = Cows

text1 = "[texta] "are faster than" [textb]"
so that it shows
text1 = Rabbits are faster than Cows

Using Office 2000

Thanks for your help,
The Saint
 
Thanks Graham,
Great to see another kiwi around here :)
Yeh I forgot to say its in a form... and im trying to attach the action to a
button.....

Cheers
The Saint

Graham Mandeno said:
Hi Saint

Yes, you do this with a calculated field (or calculated control).
Basically, what this means is that the value in the field (or control) is
calculated from an expression involving other data. This could be a simple
arithmetic or string expression or something more complex.

You create a calculated field in a query and a calculated control in a
form.

In a query, add the table(s) containing the fields you require, then add
the fields to the query grid. To make the calculated field, enter in a
blank field cell:
FieldName: Expression
(for example)
SpeedStatement: [texta] & " are faster than " & [textb]

Note that the & sign joins strings together, just like the + sign adds
numbers. This expression joins three strings. The middle one is called a
"literal string". Note that it is enclosed in quotes and also that it
includes spaces at either end (otherwise you would get "Rabbitsare faster
thanCows").

You can then bind your query to a form or report and use the field named
"SpeedStatement" just as you would use another field (except that it's not
editable).

You can also do the calculation directly in a form or report. Bind the
form/report to your table and add a textbox to it with the ControlSource:
=[texta] & " are faster than " & [textb]
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

The Boondock Saint said:
Is there a way you can have a text field = other fields

something like

texta = Rabbits
textb = Cows

text1 = "[texta] "are faster than" [textb]"
so that it shows
text1 = Rabbits are faster than Cows

Using Office 2000

Thanks for your help,
The Saint
 
Thanks for your help tome...
I forgot to say that im trying to attach it to a button in the form...

Any ideas?
Cheers
The Saint
 
I found a way to do it with your guys help,

I made another text element with your guys code in it... and made it not
visable on the form...... and then when i press the button... it takes the
value of that element and puts it into text1

Thanks for the help guys... awesome :)
 
Do you meant the Caption of a CommandButton on the Form by code???

Something like:

Me.cmdButton.Caption = texta & " are faster than " & textb]
 
You don't need an invisible textbox. Just put this code in your commoand
button click event:

text1 = texta & " are faster than " & textb
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

PS Where are you in NZ?

The Boondock Saint said:
I found a way to do it with your guys help,

I made another text element with your guys code in it... and made it not
visable on the form...... and then when i press the button... it takes the
value of that element and puts it into text1

Thanks for the help guys... awesome :)
The Boondock Saint said:
Is there a way you can have a text field = other fields

something like

texta = Rabbits
textb = Cows

text1 = "[texta] "are faster than" [textb]"
so that it shows
text1 = Rabbits are faster than Cows

Using Office 2000

Thanks for your help,
The Saint
 
Brillant ...
Thanks for that Graham, Im sure i tried it last night but i must have been
doing something wrong cause its working perfectly.

Thanks for that.
The Saint

Graham Mandeno said:
You don't need an invisible textbox. Just put this code in your commoand
button click event:

text1 = texta & " are faster than " & textb
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

PS Where are you in NZ?

The Boondock Saint said:
I found a way to do it with your guys help,

I made another text element with your guys code in it... and made it not
visable on the form...... and then when i press the button... it takes
the value of that element and puts it into text1

Thanks for the help guys... awesome :)
The Boondock Saint said:
Is there a way you can have a text field = other fields

something like

texta = Rabbits
textb = Cows

text1 = "[texta] "are faster than" [textb]"
so that it shows
text1 = Rabbits are faster than Cows

Using Office 2000

Thanks for your help,
The Saint
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top