Text Box Question

B

Bob

-I have three fields I want to link together to show in a text box on a form
i.e.:
OwnerLastName,"",OwnerFirstName,"",OwnerTitle
How should I script it...Thanks Bob







..........Jenny Vance
 
R

Richard

Try OwnerLastName & "," & OwnerFirstName & "," & OwnerTitle

Hopes this help
richard
 
B

Bob

Hmm....Got: #Name?
3 fields , OwnerLastName, OwnerFirstName, OwnerTitle
Thanks for any help...Bob
 
T

Tom Wickerath

Hi Bob (Jenny?),

You can concatenate the values together. If you know that all three fields
will never be null, you could use this expression in the control source of a
text box:

=[OwnerLastName] & " " & [OwnerFirstName] & " " & [OwnerTitle]

or this expression in the Field row of a query that serves as the form's
recordsource:

Owner: [OwnerLastName] & " " & [OwnerFirstName] & " " & [OwnerTitle]

However, it is usually better to use something like this (example given for
a query):

Owner: ([OwnerLastName]+", ") & ([OwnerFirstName]+" ") & ([OwnerTitle])

If one of the fields is null, then the entire term will be null, since a
null plus anything is still null.

Notes:
It is best to apply any sorting to the individual fields, with the check for
"Show" deselected if you do not want the individual values in the
recordsource.

Any calculated fields are not editable.


Tom Wickerath
Microsoft Access MVP

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

Tom Wickerath

Hi Bob,

The expression Richard provided to you will work as the control source of a
text box if:

1.) the fields OwnerLastName, OwnerFirstName and OwnerTitle are in the
form's recordsource. Check this out in form design view by clicking on View >
Field List.

and

2.) You use an equals sign at the beginning.

However, it is not optimized for the possibility of nulls in any of the
fields.


Tom Wickerath
Microsoft Access MVP

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

Steve Schapel

... and

3) The name of the textbox is not the same as the name of one of the fields.
 
B

Bob

Thanks everybody made a new field:
OwnerName: IIf(IsNull(tblOwnerInfo_OwnerTitle),'',tblOwnerInfo_OwnerTitle &
' ') &
IIf(IsNull(tblOwnerInfo_OwnerFirstName),'',tblOwnerInfo_OwnerFirstName & '
') & IIf(IsNull(tblOwnerInfo_OwnerLastName),'',tblOwnerInfo_OwnerLastName)
Regards Bob
 
S

Steve Schapel

Bob,

That should be ok.

Personally, I generally prefer the approach suggested by Tom. Also, I
don't think your IIf() applied to the OwnerLastName will actually
achieve anything useful. For neatness, I would do it like this...
OwnerName: [OwnerTitle]+" " & [OwnerFirstName]+" " & [OwnerLastName]

The only proviso I can think of, is that if there is a possibility that
there will be a FirstName but no LastName then the concatenated field
will end up with a trailing space, which you may want to use the Trim()
function to remove.
 
B

Bob

Thanks Steve Unless their is a LastName the record will not save
;)...........Regards Bob

Steve Schapel said:
Bob,

That should be ok.

Personally, I generally prefer the approach suggested by Tom. Also, I
don't think your IIf() applied to the OwnerLastName will actually achieve
anything useful. For neatness, I would do it like this...
OwnerName: [OwnerTitle]+" " & [OwnerFirstName]+" " & [OwnerLastName]

The only proviso I can think of, is that if there is a possibility that
there will be a FirstName but no LastName then the concatenated field will
end up with a trailing space, which you may want to use the Trim()
function to remove.

--
Steve Schapel, Microsoft Access MVP
Thanks everybody made a new field:
OwnerName: IIf(IsNull(tblOwnerInfo_OwnerTitle),'',tblOwnerInfo_OwnerTitle
& ' ') &
IIf(IsNull(tblOwnerInfo_OwnerFirstName),'',tblOwnerInfo_OwnerFirstName &
' ') &
IIf(IsNull(tblOwnerInfo_OwnerLastName),'',tblOwnerInfo_OwnerLastName)
 

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

Top