473,890 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem combining multiple rows into one

48 New Member
i am using access 2007 and i am trying to combine multiple rows into one. i am using the code from this site but i continue to get this error:
Compile error in query expression. last(concat(dat a1.company,data 1.esi))
i tried using max instead of last same error however.
Expand|Select|Wrap|Line Numbers
  1. Public Function Concat(strCOMPANY As String, _
  2.       strESI As String) As String
  3.       Static strLastCOMPANY As String
  4.       Static strESI As String
  5.  
  6.       If strCOMPANY = strLastCOMPANY Then
  7.          strESI = strESI & ", " & strESI
  8.      Else
  9.          strLastCOMPANY = strCOMPANY
  10.          strESI = strESI
  11.      End If
  12.      Concat = strESI
  13.  End Function
  14.  
my query is as follows
Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT data1.COMPANY, Last(Concat(data1.[COMPANY],data1.[ESI])) AS ESIs
  3. FROM data1
  4. GROUP BY data1.[COMPANY];
  5.  
Jan 11 '12 #1
7 1976
NeoPa
32,584 Recognized Expert Moderator MVP
It looks like you've got something from Producing a List from Multiple Records but not followed the instructions very well. You should be working with Max() (and posting that code properly - NOT typing it in).

That said, I would expect, assuming the data fits the required format, that it would work.
Jan 11 '12 #2
almaroc
48 New Member
Thanks NeoPa. it worked perfectly.
Jan 12 '12 #3
pod
298 Contributor
is there anyway to do this without the use of some VBA function call? I mean, to do it entirely within an SQL statement, ... no modules, just plain SQL
Jan 12 '12 #4
Rabbit
12,516 Recognized Expert Moderator MVP
Not with Jet SQL no. In DB2 and SQL Server you can use the built in XML functionality. In MySQL you can use a variable.
Jan 12 '12 #5
NeoPa
32,584 Recognized Expert Moderator MVP
It's a somewhat unnatural request to be fair Pod. SQL and RDBMSs are based on set theory, in which positioning is not relevant. Various systems nevertheless supply such functionality (as indicated by Rabbit's post).
Jan 12 '12 #6
pod
298 Contributor
"Various systems" always seem to be excluding Microsoft.Jet :)

The reason for my request is that I always try to put as much of the work within the SQL statement, to get as much done as possible before the rest of the code within tool takes over... but it looks like I will have to add a function ...
Jan 12 '12 #7
NeoPa
32,584 Recognized Expert Moderator MVP
Actually, Jet tends more towards providing extra towards those whose thinking is less than pure (as in pure set theory). In this case though, while it does provides the Cross-tab query, that's as far as it goes as far as I know. So, ultimately, you're still out of luck there I'm afraid.
Jan 12 '12 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

7
33322
by: RotterdamStudents | last post by:
Hello there, i have a strange problem. I can't get php to insert multiple rows at once in a MySQL database. I use the $sql = "INSERT INTO database (a,b,c,d,e) VALUES ('$a', '$b' ,'$c', '$d', '$e')"; I want to insert 5 rows at a time in the database, but it only inserts every 5th record. For example: 1. AA
4
5142
by: fip | last post by:
Hi, On DB2 7.1.2 on MVS OS 390, when I tried to do an insert with multiple row contents in the values clause: insert into table11 values('aaaa', 'fa'), ('bbbb', 'fb') I got the error: DB21034E The command was processed as an SQL statement because it
4
4893
by: don.fleming | last post by:
Hi folks: Am doing a VBA SQL Select stmt with multiple rows found and not getting RecordCount > 1. I've verified there are multiple rows found by copying my SQL stmt from Debug window and pasting it to a query - retrieves many rows. I need to program to handle many Rows in VBA. Suggestions much appreciated! Here is an excerpt of my VBA code after the SQLstmt is built: Debug.Print SQLstmt Set RecSet1 = SQLtbl.OpenRecordset(SQLstmt)
3
10735
by: manjub | last post by:
Hi, I am trying to add ability to delete multiple rows from a DataGridView in my application. When user selects multiple rows and presses delete button, I want to show a message asking to user to confirm delete. I am using UserDeletingRow event. My problem is that if 5 rows are, 5 different events are triggered. If I handle UserDeletingRow, I will have to ask for user's confirmation 5 times. Is there any way to avoid this and ask for...
5
1526
by: BerkshireGuy | last post by:
I was searching the threads about combing multiple rows into one and found some good stuff, but need your help to expand on it. I have a table as follows Policy Number DateOfTrans TransType BenefitAmt 1234 12/1/2006 Received $12,000 1234 12/3/2006 Approved $5,000 1234 12/5/2006 Paid $5,000
14
2616
by: jackiefm | last post by:
I realize the thread I am responding to was posted in January but I am basically having the same issue. I am not familiar with VBA but use Access daily. I have written simple scripts but nothing to write home about. I followed the previous thread and my situation is very similar. I have an application with users. These users have access to multiple terminals. I am trying to combine the TerminalName field with all terminals the user has access...
1
2804
by: boss1 | last post by:
i have textfile containing multiple rows.Each row containing same type of strings.now my problem is i can read only one row frequently but i can't read multiple rows. so how can i solve this problem Is there anybody expart to help me? Text to be read is: 03/31/02 04:21PM 136 11 9564499- 00:00'54 TR 03/31/02 04:22PM 202 10 8916116 00:00'05
5
1913
by: jasone | last post by:
Hi all, im nearly there with this one and im sure it shouldnt be hard to solve, i just cant seem to find the solution. ive got records being displayed, the user can then tick what records to delete... click delete.. it shows deleted records then you can go back to the screen, It works if one record is selected but any more it doesnt delete any so im sure there is a problem with my SQL statement. the code for the 2 pages have been shown...
1
1702
by: Nipun Valoor | last post by:
My query is this select (select COUNT (*) from S_PROD_REL where PAR_PROD_ID IN (select ROW_ID from s_prod_int where S_PROD_REL.PAR_PROD_ID = S_PROD_INT.ROW_ID) AND PROD_ID IN(select ROW_ID from s_prod_int where S_PROD_REL.PROD_ID = S_PROD_INT.ROW_ID)) as RowsSatisfyingValidation,(select COUNT (*) from S_PROD_REL) AS TotalNumOfRows From S_PROD_INT,S_PROD_REL; it is producing the expected result,but its being repeatedly printed m*n...
6
10921
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
9979
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9826
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,...
0
11234
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10925
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
9640
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
8018
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
7171
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();...
2
4276
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3282
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.