Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can expressions be stored in a table and then displayed on a form in a textbox?

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
579
0
16
GB
Hello,

I would like to store some default text in a settings table.

For example I would store: ="Hello" & [FirstName] & " " & "[LastName]"

I was hoping when the record was displayed in a textbox on a form it would give me the result: Hello John Smith

Unfortunately it just shows the value: "Hello" & [FirstName] & " " & "[LastName]"

Is there anyway around this?

Many thanks Mark
 
Where is [FirstName] & [LastName] coming from?

How are you transforming the placeholders into the values you require?

Why aren't you making the value of the form field your concatenation?

Or you could make the column in the table computed



"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
I do not understand why you would do this, but it is possible to run a different calculated control value for each record. So imagine I had a table with a field that contained a field called strCode. It would look like this
Code:
[tt]
ID	strCode
1	=Now()
2	=Date()
3	="The ID is: " & [ID]
4	="Today is: " & Format(date(),"dddd")
[/tt]

Then on the form I have an unbound textbox called txtbxunbound
On the form's current event I have
Code:
Private Sub Form_Current()
  If Not Me.NewRecord Then
    Me.txtBxUnbound.ControlSource = Me.strCode
  End If
End Sub
For each record it shows a different calcuated value from a different expression.

Makes no sense to me, but could be done.
 
I can't imagine why you'd want to do this - it feels like very bad-practice.

However, take the double quotes off "[Lastname]" and save that to a record, assign that record field content as the text box ControlSource - it should work as you intend.

E.g. store EXACTLY this:

Code:
="Hello " & [FirstName] & " " & [LastName]

N.B. I've added a space at the end of 'Hello'.

ATB,

Darrylle[wink]

Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top