Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

query to combine values from 2 fields and place in a 3rd field in access

Posted on 2006-05-12
10
Medium Priority
?
333 Views
Last Modified: 2010-04-17
Is there a query I could write that would take the values from 2 separate fields within the same table in an access database and combine them into a 3rd field?
Example:
field 1 contents are: A
field 2 contents are: 15
I would like field 3 to be: A15

Thanks,
Karen
0
Comment
Question by:ksilvoso
  • 5
  • 4
10 Comments
 
LVL 13

Accepted Solution

by:
bglodde earned 1000 total points
ID: 16670684
Something similar to this?
UPDATE yourtable SET field3 = (field1 + field2)
0
 
LVL 13

Assisted Solution

by:bglodde
bglodde earned 1000 total points
ID: 16670691
Make a backup first ;)
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 16671363
With Access, u want to use the string concatenator which is &

Do you want to update the table? use the update statement like bglodde has suggested except use

field1 & field2

note, not a good idea to store calculated values in a DB, as a general rule, if it can be calculated, dont store

if u just want to display, then do this

select field1 & field2 as field3
from table
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:bglodde
ID: 16671422
FYI, + works too, just tried it with MSAccess 2002
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 16671467
oh, didnt work with my access, perhaps it depends on data types? It added two numerical fields of mine
then didn one numeric, one alpha, and it came up with error
0
 
LVL 13

Expert Comment

by:bglodde
ID: 16671515
Depends on the data type - the poster has not specified, "&" works good too.
0
 
LVL 1

Author Comment

by:ksilvoso
ID: 16671700
First suggestion from bglodde worked beautfilly.  Good info from rockiroads which will help me too Thanks!
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 16673100
Interesting, when I try using +, I keep getting a conversion error. I would like to know how you and bglodde got it to work.
karen, what datatypes are u using?

Looking at your example, u wanted to add  a text to a number

I tried this, I created a text field and number field, and added  A and 3. On the update, I get a type conversion error, and select I get #Error appearing. I am using Access 2003

This is not about points, bglodde deserves them as both his accepted posts are what you wanted, Im just curious on how this worked, thats all
0
 
LVL 13

Expert Comment

by:bglodde
ID: 16674027
I used 3 columns of type text and absolutely agree that the ampersand is required for mixed data types!
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 16674094
ok, thanks bglodde, my test was based on the example give A and 15 so I used mixed data types
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Simple Linear Regression
Loops Section Overview

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question