Adding lines together to create one line

```This is probably very simple but somehow I can't remember how to concatenate
lines, so I have one line.  Here is example:
Table: Notes
OrderNo   LineNo   Note
111           1           aaa
111           2           bbb
111           3           ccc
222           1           xxx
222           2           yyy
333           1           000
333           2           111
333           3           222
333           4           333

The result should be:
Table: A
OrderNo   Note
111         aaabbbccc
222         xxxyyy
333         000111222333

I've tried with this query but it doesn't do it:
SELECT N1.OrderNo, N1.Note+N2.Note+N3.Note AS Expr1
FROM (Notes AS N1 INNER JOIN Notes AS N2 ON N1.OrderNo = N2.OrderNo) INNER
JOIN Notes AS N3 ON N2.OrderNo = N3.OrderNo
WHERE (((N1.OrderNo)=[N2].[OrderNo]) AND ((N1.LineNo)<[N2].[LineNo]) AND
((N2.OrderNo)=[N3.OrderNo]) AND ((N2.LineNo)<[N3].[LineNo]));

Could anybody help me please ?
```
 0
Utf
3/19/2010 9:18:01 PM
access.queries 6343 articles. 1 followers.

4 Replies
619 Views

Similar Articles

[PageSpeed] 52

```Try this --
SELECT OrderNo IIF([LineNo] = 1 AND [Note] Is Not Null, [Note], "") &
OrderNo IIF([LineNo] = 2 AND [Note] Is Not Null, [Note], "") & OrderNo
IIF([LineNo] = 3 AND [Note] Is Not Null, [Note], "") & OrderNo IIF([LineNo] =
4 AND [Note] Is Not Null, [Note], "") & OrderNo IIF([LineNo] = 5 AND [Note]
Is Not Null, [Note], "") AS [All_Notes]
FROM Notes;

--
Build a little, test a little.

"clalc" wrote:

> This is probably very simple but somehow I can't remember how to concatenate
> lines, so I have one line.  Here is example:
> Table: Notes
> OrderNo   LineNo   Note
> 111           1           aaa
> 111           2           bbb
> 111           3           ccc
> 222           1           xxx
> 222           2           yyy
> 333           1           000
> 333           2           111
> 333           3           222
> 333           4           333
>
> The result should be:
> Table: A
> OrderNo   Note
> 111         aaabbbccc
> 222         xxxyyy
> 333         000111222333
>
> I've tried with this query but it doesn't do it:
> SELECT N1.OrderNo, N1.Note+N2.Note+N3.Note AS Expr1
> FROM (Notes AS N1 INNER JOIN Notes AS N2 ON N1.OrderNo = N2.OrderNo) INNER
> JOIN Notes AS N3 ON N2.OrderNo = N3.OrderNo
> WHERE (((N1.OrderNo)=[N2].[OrderNo]) AND ((N1.LineNo)<[N2].[LineNo]) AND
> ((N2.OrderNo)=[N3.OrderNo]) AND ((N2.LineNo)<[N3].[LineNo]));
>
> Could anybody help me please ?
```
 0
Utf
3/19/2010 9:49:01 PM
```I'm running into syntax error.  Could this be because of "&" ?

"KARL DEWEY" wrote:

> Try this --
> SELECT OrderNo IIF([LineNo] = 1 AND [Note] Is Not Null, [Note], "") &
> OrderNo IIF([LineNo] = 2 AND [Note] Is Not Null, [Note], "") & OrderNo
> IIF([LineNo] = 3 AND [Note] Is Not Null, [Note], "") & OrderNo IIF([LineNo] =
> 4 AND [Note] Is Not Null, [Note], "") & OrderNo IIF([LineNo] = 5 AND [Note]
> Is Not Null, [Note], "") AS [All_Notes]
> FROM Notes;
>
>
> --
> Build a little, test a little.
>
>
> "clalc" wrote:
>
> > This is probably very simple but somehow I can't remember how to concatenate
> > lines, so I have one line.  Here is example:
> > Table: Notes
> > OrderNo   LineNo   Note
> > 111           1           aaa
> > 111           2           bbb
> > 111           3           ccc
> > 222           1           xxx
> > 222           2           yyy
> > 333           1           000
> > 333           2           111
> > 333           3           222
> > 333           4           333
> >
> > The result should be:
> > Table: A
> > OrderNo   Note
> > 111         aaabbbccc
> > 222         xxxyyy
> > 333         000111222333
> >
> > I've tried with this query but it doesn't do it:
> > SELECT N1.OrderNo, N1.Note+N2.Note+N3.Note AS Expr1
> > FROM (Notes AS N1 INNER JOIN Notes AS N2 ON N1.OrderNo = N2.OrderNo) INNER
> > JOIN Notes AS N3 ON N2.OrderNo = N3.OrderNo
> > WHERE (((N1.OrderNo)=[N2].[OrderNo]) AND ((N1.LineNo)<[N2].[LineNo]) AND
> > ((N2.OrderNo)=[N3.OrderNo]) AND ((N2.LineNo)<[N3].[LineNo]));
> >
> > Could anybody help me please ?
```
 0
Utf
3/20/2010 1:01:01 AM
```On Fri, 19 Mar 2010 18:01:01 -0700, clalc <clalc@discussions.microsoft.com>
wrote:

>I'm running into syntax error.  Could this be because of "&" ?
>
>"KARL DEWEY" wrote:
>
>> Try this --
>> SELECT OrderNo IIF([LineNo] = 1 AND [Note] Is Not Null, [Note], "") &
>> OrderNo IIF([LineNo] = 2 AND [Note] Is Not Null, [Note], "") & OrderNo
>> IIF([LineNo] = 3 AND [Note] Is Not Null, [Note], "") & OrderNo IIF([LineNo] =
>> 4 AND [Note] Is Not Null, [Note], "") & OrderNo IIF([LineNo] = 5 AND [Note]
>> Is Not Null, [Note], "") AS [All_Notes]
>> FROM Notes;
>>
>>

You've got a whole huge RAFT of syntax errors there. You're repeating OrderNo
over and over again, you don't have any commas or ampersands between things,
and it's not clear to me what you're even trying to do!

If you want to concatenate values from multiple records into one field, you'll
need some VBA code:

http://www.mvps.org/access/modules/mdl0004.htm

--

John W. Vinson [MVP]
```
 0
John
3/20/2010 4:43:04 AM
```You are right, I opened later and did not know how I got there.

Here are two queries that I tested and will handle up to 5 notes per orderno
--
Query-clalc_1 --
SELECT Notes.OrderNo, Max(Len(IIf([Notes].[LineNo]=1 And [Notes].[Note] Is
Not Null,[Notes].[Note],"") & IIf([Notes_1].[LineNo]=2 And [Notes_1].[Note]
Is Not Null,[Notes_1].[Note],"") & IIf([Notes_2].[LineNo]=3 And
[Notes_2].[Note] Is Not Null,[Notes_2].[Note],"") & IIf([Notes_3].[LineNo]=4
And [Notes_3].[Note] Is Not Null,[Notes_3].[Note],"") &
IIf([Notes_4].[LineNo]=5 And [Notes_4].[Note] Is Not
Null,[Notes_4].[Note],""))) AS Expr1
FROM (((Notes LEFT JOIN Notes AS Notes_1 ON Notes.OrderNo = Notes_1.OrderNo)
LEFT JOIN Notes AS Notes_2 ON Notes_1.OrderNo = Notes_2.OrderNo) LEFT JOIN
Notes AS Notes_3 ON Notes_2.OrderNo = Notes_3.OrderNo) LEFT JOIN Notes AS
Notes_4 ON Notes_3.OrderNo = Notes_4.OrderNo
GROUP BY Notes.OrderNo;

SELECT Notes.OrderNo, IIf([Notes].[LineNo]=1 And [Notes].[Note] Is Not
Null,[Notes].[Note],"") & IIf([Notes_1].[LineNo]=2 And [Notes_1].[Note] Is
Not Null,[Notes_1].[Note],"") & IIf([Notes_2].[LineNo]=3 And [Notes_2].[Note]
Is Not Null,[Notes_2].[Note],"") & IIf([Notes_3].[LineNo]=4 And
[Notes_3].[Note] Is Not Null,[Notes_3].[Note],"") & IIf([Notes_4].[LineNo]=5
And [Notes_4].[Note] Is Not Null,[Notes_4].[Note],"") AS All_Notes
FROM [Query-clalc_1] INNER JOIN ((((Notes LEFT JOIN Notes AS Notes_1 ON
Notes.OrderNo = Notes_1.OrderNo) LEFT JOIN Notes AS Notes_2 ON
Notes_1.OrderNo = Notes_2.OrderNo) LEFT JOIN Notes AS Notes_3 ON
Notes_2.OrderNo = Notes_3.OrderNo) LEFT JOIN Notes AS Notes_4 ON
Notes_3.OrderNo = Notes_4.OrderNo) ON [Query-clalc_1].OrderNo = Notes.OrderNo
WHERE (((Len(IIf([Notes].[LineNo]=1 And [Notes].[Note] Is Not
Null,[Notes].[Note],"") & IIf([Notes_1].[LineNo]=2 And [Notes_1].[Note] Is
Not Null,[Notes_1].[Note],"") & IIf([Notes_2].[LineNo]=3 And [Notes_2].[Note]
Is Not Null,[Notes_2].[Note],"") & IIf([Notes_3].[LineNo]=4 And
[Notes_3].[Note] Is Not Null,[Notes_3].[Note],"") & IIf([Notes_4].[LineNo]=5
And [Notes_4].[Note] Is Not Null,[Notes_4].[Note],"")))=[Expr1]))
GROUP BY Notes.OrderNo, IIf([Notes].[LineNo]=1 And [Notes].[Note] Is Not
Null,[Notes].[Note],"") & IIf([Notes_1].[LineNo]=2 And [Notes_1].[Note] Is
Not Null,[Notes_1].[Note],"") & IIf([Notes_2].[LineNo]=3 And [Notes_2].[Note]
Is Not Null,[Notes_2].[Note],"") & IIf([Notes_3].[LineNo]=4 And
[Notes_3].[Note] Is Not Null,[Notes_3].[Note],"") & IIf([Notes_4].[LineNo]=5
And [Notes_4].[Note] Is Not Null,[Notes_4].[Note],"");

--
Build a little, test a little.

"John W. Vinson" wrote:

> On Fri, 19 Mar 2010 18:01:01 -0700, clalc <clalc@discussions.microsoft.com>
> wrote:
>
> >I'm running into syntax error.  Could this be because of "&" ?
> >
> >"KARL DEWEY" wrote:
> >
> >> Try this --
> >> SELECT OrderNo IIF([LineNo] = 1 AND [Note] Is Not Null, [Note], "") &
> >> OrderNo IIF([LineNo] = 2 AND [Note] Is Not Null, [Note], "") & OrderNo
> >> IIF([LineNo] = 3 AND [Note] Is Not Null, [Note], "") & OrderNo IIF([LineNo] =
> >> 4 AND [Note] Is Not Null, [Note], "") & OrderNo IIF([LineNo] = 5 AND [Note]
> >> Is Not Null, [Note], "") AS [All_Notes]
> >> FROM Notes;
> >>
> >>
>
> You've got a whole huge RAFT of syntax errors there. You're repeating OrderNo
> over and over again, you don't have any commas or ampersands between things,
> and it's not clear to me what you're even trying to do!
>
> If you want to concatenate values from multiple records into one field, you'll
> need some VBA code:
>
> http://www.mvps.org/access/modules/mdl0004.htm
>
> --
>
>              John W. Vinson [MVP]
> .
>
```
 0
Utf
3/21/2010 4:41:01 PM

Similar Artilces:

Removing spaces at start of line
Hi, Is there a way to remove spaces at the beginning of lines in a Word 2007 doc? I don't want to remove the spaces between the words, just at the beginning of each line. Thanks! Select the text. Set justification to centered and then set justification back to left. Jill wrote: > Hi, > > Is there a way to remove spaces at the beginning of lines in a Word > 2007 doc? I don't want to remove the spaces between the words, just > at the beginning of each line. > > Thanks! If you have spaces at the beginning of a line, it probably means...

Adding Blank Rows after the last Detail of the Report
Hi All, I've used this code from Dwayne: Private Sub Report_Page() Dim intNumLines As Integer Dim intLineNumber As Integer Dim intTopMargin As Integer Dim ctl As Control Dim intLineHeight As Integer intNumLines = 12 intTopMargin = Me.Section(3).Height intLineHeight = Me.Section(0).Height For Each ctl In Me.Section(0).Controls For intLineNumber = 0 To intNumLines - 1 Me.Line (ctl.Left, intTopMargin + _ (intLineNumber * intLineHeight)) - _ Step(ctl.Width, intLineHeight), , B Next Next End Sub My report needs to print blank rows (at least...

Hey everybody I have a batch file which needs to be run from an excel sheet with a parameter, like this: c:\1.bat myParameter But when i try to run the Hyperlink, the Excel shows an error message saying it can't open the specified file (probably because the is a space between the file and the parameter) is there any known way to run the link from the excel? On Mar 2, 12:45=A0pm, Pasha <pavel_v...@mailto.mod.gov.il> wrote: > Hey everybody > I have a batch file which needs to be run from an excel sheet with a > parameter, like this: > c:\1.bat myParameter > But when i ...

Contacts
Is there a way to create a household contact For example, I have one common home phone number, email address, and street address for a couple in my contact list. I would like to enter individual names and birthday dates but only one anniversary date and have all dates show up on my calendar If possible, can this idea be expanded to childrens names and birthdays fo rthe same household? ...

two domains in one outlook profile
Hey, Is there a way to choose what address shows up on the Sent From line in outlook. I have a users, all in one exchange server, who need to have their FROM LINE display a different domain then their main reply email. Both addresses are set up on their exchange account, so then can receive emails when an email is sent to user@domain1.com and user@domain2.com. By default, when they create a new email, the recipient will always see @domain1.com. Is there a way to choose what domain shows up in the FROM line so that when they need to send to certain recipients, the recipient sees ...

outlook vcard, ad integration user properties
my boss is trying to get hix fax# in his vcard. he is using his address from the global address list I have modified his profile in active directory users and computers: I go into AD users and computers, double click on his user, go to the telephones tab, and enter his fax #. but when I did this his fax # is still not being pulled up in his outlook vcard. Does anyone know where outlook is trying to get this field from / how i can get this field into his vcard? thx ...

Line & Double Stacked Charts
Good day. I am trying to get a Double stacked chart to show a line. I can get the line by creating a secondary Axis however the line isnt where I want it. It is at the top of the tallest bar. Is there any way to get the line down to a value I want it at. Basically I am trying to create a capacity chart with two products running on one machine by month. I need the line to be at a value that is straight accross being the maximum machine capacity. Any help would be greatly appreciated. Thanks "K" wrote: > Good day. I am trying to get a Double stacked chart to show a line...

how do i add a number to a range of cells? I need to add 11.27 to a number of different cells each with a different number in them Put 11.27 in an empty cell, format it the same way as the numbers you want to add to, copy it, then select the numbers you want to add to and do edit>paste special and select add. -- Regards, Peo Sjoblom "Helpme" <Helpme@discussions.microsoft.com> wrote in message news:6D51344A-78E6-4377-B292-FC6C16FF6BA2@microsoft.com... > how do i add a number to a range of cells? I need to add 11.27 to a > number > of different cells e...

I am totally new to CRM, so I hope this is really easy question: This concerns permissions.. I have a "sales" group, and with one of those people i need to be able to let them add new records on behalf of other "sales" people. Is there like a standard permission setting for it? (obviously every "sales" person can add new records if they select them selfs as the owner) thanks, Michal. Hi, By default the person who creates the record will be the owner. After record creation the person could reassign the record (manually) to another user. If all rec...

....in Outlook the following errors comes up: "Out of memory or system resources, please close some programs and try again" Quotas are fine. I have deinstalled/reinstalled Office, cleaned 'temp' areas, and many other tidbits. Any other ideas? Thanks. This might help as i had this problem with Outlook 98. Is the file you are trying to copy to attach nested in sub folders? if so try and copy the attachment to a root drive like c:\ Ignore previous email. wrong spellin if the attachment is nested in sub folders(this means you have to open different folders to get to ...

Picture Disappears When Added To Contact In Outlook 2003
Can someone help please. When I try to attach a picture to a contact in outlook 2003 immediately I double click the picture to be attached it disappears out of the outlook contact along with the placement holder in the form. Only when I right click the mouse and go remove picture do I get the placement holder back. I have looked at all the help menus but they offer no clues. Thanks TS ...

Y-Error Bars
I am having trouble putting a y-error bar on one data point in my series. Excel wants to add error bars to all points (bars) in the series. Is there a way to do this? Thanks. Hi Diana, To get error bars on a single bar you can use the Custom +/- reference boxes on the Error bar tabs. Use this to get your values from worksheets cells. Obviously within the cells are zero values for all but the bar your want. Cheers Andy Diana wrote: > I am having trouble putting a y-error bar on one data > point in my series. Excel wants to add error bars to all > points (bars) in the ...

Select ALL filter in one fell swoop
Sometimes it is difficult to see all the columns which has a filter applied, is there a convenient way to select the ALL option on a filter for all the filters in the sheet. I do not want to remove the filter only have a handy way of not having the filter applied. there could be up to 6 columns filtered on the sheet at the same time. Choose Data>Filter>Show All Pat wrote: > Sometimes it is difficult to see all the columns which has a filter > applied, is there a convenient way to select the ALL option on a filter for > all the filters in the sheet. I do not want to remov...

Adding ActiveX to dialog with wrapper
When I add an ActiveX object to a dialog using the dialog editor - right click - insert activeX object, the help on the resulting activex selection tool states that a wrapper will not be added by using this method. If you need a wrapper, it suggests using the class view. This is using Visual Studio 2005. I'm having some problems with this on an existing project. To make sure I understand the process, I created a new MFC project, added a dialog, created a class for that dialog and added a Flexgrid object using the right click method in the dialog. I then added a variable for the flexgrid...

Create an arch
I would like to build an arch of individual bricks. I have created an arch but do not know how to place each brick so that they all aligh correctly to form the arch. Is there and easy way in Visio to do this? Thanks Do you want to create an arch with a brick pattern, where the arch actually cuts into the bricks? Or do you want to stack the bricks so that they form an arch? The latter might be tricky and time-consuming; but the former would be easy enough to do. For instance, you could create the brick pattern first, copy the bricks to make a wall that measures the apex height and base width...

I work on a schedule where I record ticket count and ticket sales for each show, listed chronologically. Column A = week ending date Column B = # Tickets sold for April 5 show Column C = Ticket Revenue for April 5 show Column D = # Tickets sold for April 9 show Column E = Ticket Revenue for April 9 show Column F = # Tickets sold for April 12 show Column G = Ticket Revenue for April 12 show Column H = Total # Tickets sold for all shows Column I = Total Ticket Revenue for all shows In the Totals columns, the Total Tickets formula is "+B4+D4+F4", and the Total Revenue f...

Adding fields from a different query
I have a form built based on a main query. How do I add more fields on that form that come from a different query? Anne A couple possibilities... Change your first query to include the extra fields. Use your second query to "feed" a form, then embed that form as a subform on your main form. Good luck! Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein does not constitute endorsement thereof. Any code or pseudoco...

Adding more than three Conditions to 'Conditional Formatting'
Can i add more than three conditions to the conditional formatting presets using code? Regards [Riz] -- Rizitsu ------------------------------------------------------------------------ Rizitsu's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=15840 View this thread: http://www.excelforum.com/showthread.php?threadid=320382 Riz, as you have found out, only 3 conditions with conditional formatting. But yes you can use some code to get more than 3, try this it will change the cell color in column A when you put in one ,two, three, or four, right click on the she...

Delimiter for adding Appointment in Entourage
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Power PC Email Client: Exchange What's the delimiter that Entourage uses if I want to add an appointment and the subject needs to be parsed by the Exchange server? <br><br>In Outlook, the hash/pound key (#) is used as delimiter. How about in Entourage 2008? <br><br>Basically, if I add an entry in a group calendar Out-Of-Office with the subject: #User1# On-Leave <br><br>in Outlook, this entry appears in the group calendar Out-Of-Office and also in User1's personal calendar. <...

find duplicated lines in excel sheet
I have an excel sheet with text column. I wish to find and remove some duplicated lines. How can I do it? If I can do it with Excel? I've tried google for this task and found freeware tool for finding duplicated - http://www.aks-labs.com/support/phpBB2/viewtopic.php?t=69 it was good for my task, but if I can do something better with Excel? Thank you! You could use conditional formatting for the column with duplicates. http://www.contextures.com/xlCondFormat03.html#DupColumn Alan" <allangrlind@yahoo.com> wrote in message news:1122245733.329829.213230@g43g2000cwa.googlegr...

Extracting a list of individual values created with sum of values
Hello All, The following code sums values created using 2 ^ n for various invalid data. There is a method of then extracting the individual values from the summed total to identify the individual messages. I canâ€™t remember how to do this and have not been successful in finding it so any help will be appreciated. I know there are other ways of creating the list of messages but I particularly want the code for this method. (The code below is simply an example. What I am really after is code to create an individual number to use as an argument/parameter in a different situation....

Merging line of credit accounts
Is it possible to merge two separately named line of credit (LOC) accounts. They are actually the same account. I have merged two bills accounts by renaming one of them to match the other; but when I try this approach on the LOC accounts, Money 2004 tells me the second name is already in use, try a different name. I'm not sure, but you may try (AFTER backing up!) exporting the non-surviving account to QIF, then importing it and telling Money to import to the surviving account. After doing so and confirming that the transactions are all now in the intended account, delete the non...

Is there a listing somewhere of what all components in AD should be minitored, thresholds, etc...we are evaluating a monitoring solution and need this information to take a decision on the product to use Hello Sameer, For performance start here: http://technet.microsoft.com/en-us/library/cc961943.aspx Also see: http://technet.microsoft.com/en-us/library/bb727046.aspx Use the included links from: http://technet.microsoft.com/en-us/library/cc739728(WS.10).aspx Best regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties, and c...

Adding Terms & Conditions to the Quote Form
We have a client that would like to add their Terms & Conditions (T&C) text to the bottom of their GP Quotes. I've read that static text boxes in Report Designer can only be 80 characters, so that won't work as the T&C text is approximately 4-5 pages long. Does anyone have any suggestions on how to add this significant amount of text to a GP form? Thank you in advance. Scott No can do Scott - Report Writer is just not capable of this. The best solution is to purchase Accountable Software's Forms Printer - www.accountable.com. Frank Hamelly MCP-GP, MCT, MVP East...