473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Combining two text field into a long list

Hello Experts!

I would like to combine (which may not be the correct technical term) two
text fields from the same table in a query. Specifically, text field A and
text field B are both lists of names. My goal is to have one long list of
all the names, not A next to B like one gets when you use the & operator.
The eventual goal is to be able to print labels of all the individuals. I
have no problem creating a label-Report from the Query. It appears I can not
use the OR operator since these are two separate fields in the original
table.

I hope this is clear. Thanks.

Justin
Jan 17 '06 #1
4 3475
"justin tyme" <ns************@yahoo.com> wrote
I would like to combine (which may not be the
correct technical term) two text fields from the
same table in a query. Specifically, text field A and
text field B are both lists of names.


What, exactly, is the format of the text field that contains a "list of
names"? You mean two text fields in the very same record contain many names?
Are they on separate lines, delimited by commas, or ??? And how do you want
the resulting list to appear?

Larry Linson
Microsoft Access MVP
Jan 17 '06 #2
Justin, I'm not really clear here, but I think you have person in field A,
and another person in field B, and you want to make a label for every person
in both fields.

If that's the idea, you can create a UNION query that combines the people
from both fields into one long list. Access cannot show you a UNION query
graphically, but try this:
1. Create a query that gets the name from field A, and all the other fields
you want for your labels.

2. In the Field row in front of field A, enter an alias and a colon, such
as:
ThePerson: [A]
In the Criteria row under this field, enter:
Is Not Null

3. Create a second query that gets the same fields in the same order, but
uses field B instead of A.

4. Use the same alias:
ThePerson: [b]
and the same Criteria:
Is Not Null

5. Switch both queries to SQL View (View menu.)

6. In the first query, replace the trailing semicolon with:
UNION ALL
and paste in all the text of the 2nd query statement.

You will end up with something like this:

SELECT [A] AS ThePerson, Address, City, Zip
FROM [Table1]
WHERE A is Not Null
UNION ALL
SELECT [b] AS ThePerson, Address, City, Zip
FROM [Table1]
WHERE [b] Is Not Null;
Optional Extensions
===============
a) If you want the query to deduplicate the names form fields A and B,
change:
UNION ALL
to just:
UNION

b) If you want to know which field a name came from, add a calculated field,
e.g.:
SELECT [A] AS ThePerson, "FieldA" AS TheSourceField, City
FROM [Table1]
WHERE A is Not Null
UNION ALL
SELECT [b] AS ThePerson, "FieldB" AS TheSourceField, City
FROM [Table1]
WHERE [b] Is Not Null;

c) If you want to sort the query, add an ORDER BY clause to end of the query
statement. (Generally this doesn't matter, as you use the Sorting And
Grouping box in your report (View menu in Report Design view) to handle the
sorting.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"justin tyme" <ns************@yahoo.com> wrote in message
news:vX*****************@newsread2.news.pas.earthl ink.net...
Hello Experts!

I would like to combine (which may not be the correct technical term) two
text fields from the same table in a query. Specifically, text field A and
text field B are both lists of names. My goal is to have one long list of
all the names, not A next to B like one gets when you use the & operator.
The eventual goal is to be able to print labels of all the individuals. I
have no problem creating a label-Report from the Query. It appears I can
not use the OR operator since these are two separate fields in the
original table.

I hope this is clear. Thanks.

Justin

Jan 17 '06 #3
On Tue, 17 Jan 2006 01:41:47 GMT, "justin tyme" <ns************@yahoo.com> wrote:
Hello Experts!

I would like to combine (which may not be the correct technical term) two
text fields from the same table in a query. Specifically, text field A and
text field B are both lists of names. My goal is to have one long list of
all the names, not A next to B like one gets when you use the & operator.
The eventual goal is to be able to print labels of all the individuals. I
have no problem creating a label-Report from the Query. It appears I can not
use the OR operator since these are two separate fields in the original
table.

I hope this is clear. Thanks.

Justin


You would need to use a union query.

SELECT FieldA As ListName FROM tblMyTable
UNION SELECT FieldB FROM tblMyTable;
Wayne Gillespie
Gosford NSW Australia
Jan 17 '06 #4
Thanks to all. I had never heard of the UNION function. In fact, I went
back to my 423 page instructional manual, and it was not even listed!

justin

"justin tyme" <ns************@yahoo.com> wrote in message
news:vX*****************@newsread2.news.pas.earthl ink.net...
Hello Experts!

I would like to combine (which may not be the correct technical term) two
text fields from the same table in a query. Specifically, text field A and
text field B are both lists of names. My goal is to have one long list of
all the names, not A next to B like one gets when you use the & operator.
The eventual goal is to be able to print labels of all the individuals. I
have no problem creating a label-Report from the Query. It appears I can
not use the OR operator since these are two separate fields in the
original table.

I hope this is clear. Thanks.

Justin

Jan 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kenneth Fosse | last post by:
Hi. I'm currently working on a project which involves the creation of a web page which reports selected data to customers from two back-end systems. I use ASP script language on IIS, the server...
2
by: Kristian | last post by:
Hey, I have some problems combining 2 fields in a query. For example: the first field is "1050-04" and the second field is "02". However, when i try to combine these two the zero in the...
2
by: Max | last post by:
Hello everyone, I have a task of combining two tables: tblPatient and tblSolution, related by a KEY field in a one-to-many relationship from tbl Patient to tblSolution, respectively. So, I have...
4
by: Omey Samaroo | last post by:
Dear Access Gurus, Can anyone provide me with some much needed assistance. I would like to combine the contents of 3 text fields into one field. Can someone provide some code or a method to do...
1
by: John Smith | last post by:
I am trying to combine two lookup fields into one field for display on a form and a report. I understand the basics behind how to do this: I set the control source for a new text box control to...
6
by: Aussie Rules | last post by:
Hi, I have a datepicker that show a calender. The user picks a date and the time component is always 00:00. I then have a drop down that provides a list of times, (10:00, 11:00 etc), and I...
1
by: datasec23 | last post by:
Hi... I really appreciate your help with my question, I am pulling my hair out on this. I have not been able to find an answer on the other posts. I am using Access 2000. I have a form that...
5
by: MLH | last post by:
I'm using A97 import data wizard to import text file N2 a table. The text file is a DIR listing produced by running dir jdc*.* /s c:\JDCs.txt The wizard is chopping the lines off at the...
15
by: pakerly | last post by:
How would i do this, convert a test file to excel? Lets say my text file has fields like this: NUMBER NAME ADDRESS PHONE 11002 Test1 ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.