OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

[Solved] Combining data from 2 fields into a 3rd field

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
JRachel973
Newbie
Newbie


Joined: 31 May 2007
Posts: 4

PostPosted: Wed Apr 11, 2012 12:44 pm    Post subject: [Solved] Combining data from 2 fields into a 3rd field Reply with quote

I am putting together an address book where I have a field "First Name", another field "Last Name", and a 3rd field "Full Name". How do I format the "Full Name" field so when I enter the "First Name" and the "Last Name", it automatically shows the contents of the "First Name" and "Last Name" together in the "Full Name" field? Like this:
"First Name": John (entered)
"Last Name": Doe (entered)
"Full Name": John Doe (automatically entered)

I'm sure this must have been discussed somewhere, but I've searched for days and couldn't find anything. I'm pretty new at this, so any help would be appreciated Exclamation

Tagged as solved - floris v, moderator
Back to top
View user's profile Send private message
floris_v
Moderator
Moderator


Joined: 12 Jul 2007
Posts: 4791
Location: Netherlands

PostPosted: Wed Apr 11, 2012 12:48 pm    Post subject: Reply with quote

You don't. You can use any kind of control, but the text is simply composed of the First name and Last Name fields with a space in between.
_________________
LibreOffice 3.6.3; OOo 3.4.1 on Windows Vista
Join the Official community forum - in several languages, including Nederlandstalig forum
Back to top
View user's profile Send private message
JRachel973
Newbie
Newbie


Joined: 31 May 2007
Posts: 4

PostPosted: Wed Apr 11, 2012 7:07 pm    Post subject: Reply with quote

Ok, something is amiss here. Here's what's going on:

1) The Address Table contains the 3 fields: FirstName, LastName, & FullName. All fields have the field type "Text [VARCHAR]. "Entry Required" FirstName and LastName are set to "Yes" FullName is set to "No". There are no "Default Value" settings in all 3 fields. All 3 fields have a "Length" of 50.

2) In the form, all 3 fields are "text boxes". In the FirstName and Last Name Text Box, the Control...Properties:Text Box...Data tab...Data Field are linked to the same fields in the table. In the LastName Data field I typed in the FirstName (space) LastName fields, closed the Properties window, and saved the Form. When I opened the Form, the FullName Text Box was empty. After several trials I realized that only ONE table field can be entered in the Data field (they are listed in the adjacent drop-down selection). So, when I entered the field "FirstName", its corresponding data appeared. The same held true when entering the "LastName" field; but not when both were entered.

Obviously I'm doing something wrong. Am I missing the obvious? Embarassed
Back to top
View user's profile Send private message
dacm
Super User
Super User


Joined: 07 Jan 2010
Posts: 769

PostPosted: Wed Apr 11, 2012 10:19 pm    Post subject: Reply with quote

That's true. You cannot bind a Form Control like a Text Box to more than one Data field. However, you can achieve your objective:
    (1) Eliminate the FULLNAME field in your table. It's not necessary, and simply redundant.
    (2) Base your Form on an 'SQL command' or 'Query' that includes (as a minimum) the record ID (primary key field), FIRSTNAME, LASTNAME, and a pseudo field generated with SQL Concatentation and with the alias FULLNAME. In this case the Form would be based on the following Form Properties > Data (tab) > Content type > SQL command > Content:
    Code:
    SELECT "ID", "FIRSTNAME", "LASTNAME", "FIRSTNAME" || ' ' || "LASTNAME" AS "FULLNAME" FROM "CONTACTS"

    (3) Save the record to see the FULLNAME in the dedicated Text Box.

Here's a quick demo of the above steps/concepts:
Contacts_fullname_demo.odb or mirror: Contacts_fullname_demo.odb
_________________
Soli Deo gloria
Tutorial: avoiding data loss with Base + Splitting 'Embedded databases'
Back to top
View user's profile Send private message
JRachel973
Newbie
Newbie


Joined: 31 May 2007
Posts: 4

PostPosted: Mon Apr 16, 2012 7:01 pm    Post subject: Reply with quote

Ok! Got it! The form works perfectly. Thanks for all your help. Very Happy
Back to top
View user's profile Send private message
Billyray
OOo Enthusiast
OOo Enthusiast


Joined: 06 Mar 2007
Posts: 144
Location: Lake Erie's Shore in Ohio

PostPosted: Tue Apr 17, 2012 6:11 am    Post subject: Reply with quote

Don't forget to "edit" the first post in this thread, and add "[SOLVED]" to the Title. Wink
_________________
Billyray
using:
Linux distro: Ubuntu 10.04 LTS, Lucid Lynx, OOo Base 3.3, connected to MySql database using Java jdbc (note: ONLY sun-java-6-1.6.0_22 jre works right), and converted from MS Access 2003.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group