| View previous topic :: View next topic |
| Author |
Message |
JRachel973 Newbie


Joined: 31 May 2007 Posts: 4
|
Posted: Wed Apr 11, 2012 12:44 pm Post subject: [Solved] Combining data from 2 fields into a 3rd field |
|
|
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
Tagged as solved - floris v, moderator |
|
| Back to top |
|
 |
floris_v Moderator


Joined: 12 Jul 2007 Posts: 4618 Location: Netherlands
|
Posted: Wed Apr 11, 2012 12:48 pm Post subject: |
|
|
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 |
|
 |
JRachel973 Newbie


Joined: 31 May 2007 Posts: 4
|
Posted: Wed Apr 11, 2012 7:07 pm Post subject: |
|
|
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?  |
|
| Back to top |
|
 |
dacm Super User


Joined: 07 Jan 2010 Posts: 734
|
Posted: Wed Apr 11, 2012 10:19 pm Post subject: |
|
|
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 + Migrating 'Embedded databases' |
|
| Back to top |
|
 |
JRachel973 Newbie


Joined: 31 May 2007 Posts: 4
|
Posted: Mon Apr 16, 2012 7:01 pm Post subject: |
|
|
Ok! Got it! The form works perfectly. Thanks for all your help.  |
|
| Back to top |
|
 |
Billyray OOo Enthusiast


Joined: 06 Mar 2007 Posts: 144 Location: Lake Erie's Shore in Ohio
|
Posted: Tue Apr 17, 2012 6:11 am Post subject: |
|
|
Don't forget to "edit" the first post in this thread, and add "[SOLVED]" to the Title.  _________________ 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 |
|
 |
|