473,804 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Combining multiple columns into one row in one field

I have a table, tblManinstructi ons with fields Code & InstructionID, one
Code can have many InstructionID. I also have tblinstructions (fields
instructionID & instruction). What I want to do is create a table with the
fields Code and Instruction - a combination of all instructions from the
instruction IDs in tblManinstructi ons). E.g. Code 1234 currently has 4
fields in tblManinstructi ons, instructionIDs 28, 43 & 76. The new table I
want to create will have one row with the instructions of Ids 28,43 & 76 in
one field, separated by commas. Can anyone help?

thanks
Nov 13 '05 #1
2 3411
I understand you have multiple fields with the same meaning (InstructionID)
in the main record. If I am wrong, please clarify. If I am correct in my
understanding, that is not a good idea because it will cause problems for
you, sooner or later.

For example, sometime , you'll have a need to join tblMaininstruct ions and
tblInstructions ... for a report, perhaps. If you had a foreign key to
tblMaininstruct ions in tblInstructins (if it is one to many) or a junction
table with foreign keys to both (if many to many), that would be easy. And,
when that comes up, expect to hear the same again from many sources.

You omitted an important part, which is the names of the multiple
InstructionID fields in tblMaininstruct ions. For brevity, I will use ID1,
ID2, ID3, and ID$ for this example:

ID1 & (", "+ ID2) & (", "+ ID3) & (", "+ ID4)

should give you the result that you want, presuming that if there are any
IDs, there will be an ID1. The + operator for concatenation results in a
Null if either of the operands is Null; the & operator treats Null as if it
were an empty string, so the result is not Null.

Larry Linson
Microsoft Access MVP

"Will" <Wi************ @hotmail.com> wrote in message
news:3i******** ****@individual .net...
I have a table, tblManinstructi ons with fields Code & InstructionID, one
Code can have many InstructionID. I also have tblinstructions (fields
instructionI D & instruction). What I want to do is create a table with the
fields Code and Instruction - a combination of all instructions from the
instruction IDs in tblManinstructi ons). E.g. Code 1234 currently has 4
fields in tblManinstructi ons, instructionIDs 28, 43 & 76. The new table I
want to create will have one row with the instructions of Ids 28,43 & 76 in
one field, separated by commas. Can anyone help?

thanks

Nov 13 '05 #2
Firstly, thanks for your help,
tblManInstructi ons is my link table and has two fields - ProductCode and
InstructionID. These fields are both foreign keys, linking to
tblInstructions & tblProducts. I'm not sure whether this is right, but it
is how I inherited it! I am trying to convert it to a table where the
relationship is one product to one instruction. The multiple InstructionID
fields in tblManinstructi ons all have the same name - InstructionID - there
are just multiple records for each Instruction. I am trying to join columns
together rather than rows.

"Larry Linson" <bo*****@localh ost.not> wrote in message
news:IQdye.326$ Gv3.318@trnddc0 2...
I understand you have multiple fields with the same meaning (InstructionID)
in the main record. If I am wrong, please clarify. If I am correct in my
understandin g, that is not a good idea because it will cause problems for
you, sooner or later.

For example, sometime , you'll have a need to join tblMaininstruct ions and
tblInstructions ... for a report, perhaps. If you had a foreign key to
tblMaininstruct ions in tblInstructins (if it is one to many) or a junction
table with foreign keys to both (if many to many), that would be easy.
And, when that comes up, expect to hear the same again from many sources.

You omitted an important part, which is the names of the multiple
InstructionID fields in tblMaininstruct ions. For brevity, I will use ID1,
ID2, ID3, and ID$ for this example:

ID1 & (", "+ ID2) & (", "+ ID3) & (", "+ ID4)

should give you the result that you want, presuming that if there are any
IDs, there will be an ID1. The + operator for concatenation results in a
Null if either of the operands is Null; the & operator treats Null as if
it were an empty string, so the result is not Null.

Larry Linson
Microsoft Access MVP

"Will" <Wi************ @hotmail.com> wrote in message
news:3i******** ****@individual .net...
I have a table, tblManinstructi ons with fields Code & InstructionID, one
Code can have many InstructionID. I also have tblinstructions (fields
instruction ID & instruction). What I want to do is create a table with
the fields Code and Instruction - a combination of all instructions from
the instruction IDs in tblManinstructi ons). E.g. Code 1234 currently has
4 fields in tblManinstructi ons, instructionIDs 28, 43 & 76. The new table
I want to create will have one row with the instructions of Ids 28,43 & 76
in one field, separated by commas. Can anyone help?

thanks


Nov 13 '05 #3

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

Similar topics

6
5634
by: Dennis | last post by:
In CSS3 it looks like we'll have multiple column flowing of text (newspaper style) in which the number of columns can be determined automatically given the available horizontal space. http://www.w3.org/TR/css3-multicol/ Until then, what's the current best practice for achieving the same effect? Or is it just not possible yet? Thanks ... Dennis
16
6903
by: lostinspace | last post by:
Is it possible? TIA
7
7702
by: Billy Jacobs | last post by:
I am using a datagrid to display some data. I need to create 2 header rows for this grid with columns of varying spans. In html it would be the following. <Table> <tr> <td colspan=8>Official Impact Summary</td> </tr> <tr> <td colspan=2></td>
3
2647
by: Jane | last post by:
Hi, If anyone could help me with this, I greatly appreciate it. I would like to know how I can display data from a db in multiple columns rather than have it displayed in 1 column per recordset. Here is a twist...besides doing this, I would also like to have it paginate and be able to control how many records gets displayed per page in multiple columns. Thank y'all in advance!!!
2
2822
by: Beacher | last post by:
Morning all, I have a listbox, and I want to populate it with a table.. right now the listbox's rowsource is set to SELECT * FROM tblCondition but it only grabs the first field from the table and lists that field down the listbox, how can I have multiple columns of all the fields from the table in the listbox?
3
1502
by: Regnab | last post by:
I have four columns in one table. I want to add all the records in each of these columns into 1 column in another table. Any ideas??
2
10513
by: ray well | last post by:
i need to display 2 columns of data in a list box. how would i set this up IN CODE. say my table is tblNames, and i have 2 fields, FirstName, LastName, and want the data to show up in 2 columns, LastName, followed by FirstName normally i would say ListBox1.DataSource = DataSet1.Tables("tblNames")
3
20847
by: Will | last post by:
Can someone help with code to delete multiple columns from an excel spreadsheet? I know which columns I need to delete. The code below will delete a single column but I'm not sure how to delete multiple columns. I'm tried experimenting with Dim rg As Excel.Range = xlSheet.Columns("B, D, G, K, L") but no joy. Thanks in advance Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet
6
10918
by: Jeremy Goodman | last post by:
Access 2007; Merging records containing multivalue drop down lists. I have a database showing legislation information divided by State/territory. The database needs to be able to show the info from each legislation and then an overall picture for the state. There is no problem with merging some of the info using the steps in: http://bytes.com/topic/access/answers/589999-combining-multiple-rows-one-field-into-one-result The problem is...
0
9595
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10356
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9176
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.