473,395 Members | 2,079 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,395 software developers and data experts.

How do I combine Multiple Rows of data into One Row.

I have designed a Database that will import data and assign values for ordering material. However I am having problems as I currently have to drop this data into an Excel sheet and apply a Pivot Table to it to manipulate the results. I believe that there is a way to do this in Access, however I have been unsuccessful. Hopefully someone out here will be able to assist me. Using some samples I found on other posts here. I have created the following.

Table has data like:

AlphaNumeric WallMark#
AA4 4001
AA4 4008
AB4 4008
AB4 4014

I need it to show like:

AlphaNumeric WallMark#
AA4 4001, 4008.
AB4 4008, 4014.

I have written a Class Module: (as shown here)

================================================== =======
Option Compare Database

Public Function CONCAT(strAlphaNumeric As String, strWallMark#) As String
Static strLastAlphaNumeric As String
Static strPanelInfo As String

If strAlphaNumeric = strLastAlphaNumeric Then
strPanelInfo = strPanelInfo & ", " & strWallMark#
Else
strLastAlphaNumeric = strAlphaNumeric
strPanelInfo = strWallMark#
End If
CONCAT = strPanelInfo

End Function
================================================== =======

And yes I have Compiled and Saved it.


Also, here is the SQL query:

================================================== =======
SELECT AlphaNumeric, Last(CONCAT(AlphaNumeric,[WallMark#])) AS PanelInfo
FROM [TEST TABLE]
GROUP BY AlphaNumeric
================================================== =======

All I keep getting is:

================================================== =======
Undefined function 'CONCAT' in expression.
================================================== =======

Any idea how I can get this to work? I would appreciate any suggestions. Note you can e-mail me at "concathelp@rogers.com".

Thanks.
Jan 16 '08 #1
8 22762
PianoMan64
374 Expert 256MB
I have designed a Database that will import data and assign values for ordering material. However I am having problems as I currently have to drop this data into an Excel sheet and apply a Pivot Table to it to manipulate the results. I believe that there is a way to do this in Access, however I have been unsuccessful. Hopefully someone out here will be able to assist me. Using some samples I found on other posts here. I have created the following.

Table has data like:

AlphaNumeric WallMark#
AA4 4001
AA4 4008
AB4 4008
AB4 4014

I need it to show like:

AlphaNumeric WallMark#
AA4 4001, 4008.
AB4 4008, 4014.

I have written a Class Module: (as shown here)

================================================== =======
Option Compare Database

Public Function CONCAT(strAlphaNumeric As String, strWallMark#) As String
Static strLastAlphaNumeric As String
Static strPanelInfo As String

If strAlphaNumeric = strLastAlphaNumeric Then
strPanelInfo = strPanelInfo & ", " & strWallMark#
Else
strLastAlphaNumeric = strAlphaNumeric
strPanelInfo = strWallMark#
End If
CONCAT = strPanelInfo

End Function
================================================== =======

And yes I have Compiled and Saved it.


Also, here is the SQL query:

================================================== =======
SELECT AlphaNumeric, Last(CONCAT(AlphaNumeric,[WallMark#])) AS PanelInfo
FROM [TEST TABLE]
GROUP BY AlphaNumeric
================================================== =======

All I keep getting is:

================================================== =======
Undefined function 'CONCAT' in expression.
================================================== =======

Any idea how I can get this to work? I would appreciate any suggestions. Note you can e-mail me at "concathelp@rogers.com".

Thanks.
the main reason that is not working it because you have defined it as a class module. It needs to me simply a module. It can't be defined in a form and it can't be defined as a class. You need to put it into a Regular Module, and make it public, then it will work for you.

Hope that helps,

Joe P.
Jan 22 '08 #2
the main reason that is not working it because you have defined it as a class module. It needs to me simply a module. It can't be defined in a form and it can't be defined as a class. You need to put it into a Regular Module, and make it public, then it will work for you.

Hope that helps,

Joe P.
Joe Appreciate your reply...I have made this a Regular Modular and tried again...still no luck.

Any other suggestions?
Jan 22 '08 #3
NeoPa
32,556 Expert Mod 16PB
Check out these threads :
(Combining Multiple Rows of one Field into One Result)
(Combining Rows-Opposite of Union)
I hope you find something there to help.
Jan 22 '08 #4
NeoPa,

Thanks for the information...I have been away for the last few days...I will try it out and get back to you.

MIke
Jan 26 '08 #5
NeoPa
32,556 Expert Mod 16PB
No probs Mike.
I think Cross-Tab queries are another method that might be worth a look at. You decide which suits your needs the closest ;)
Jan 26 '08 #6
NeoPa,

I am still getting the error message. There is only one difference in the Module that I can see. In Mine (as shown below) on line 2.

I tried to have line 2 show as

strWallMark# As String) As String

but it won't let me put in the extra As String as shown in your example. Any idea why it won't?
Expand|Select|Wrap|Line Numbers
  1. Public Function CONCAT(strAlphaNumeric As String, _
  2.                         strWallMark#) As String
  3.  
  4.        Static strLastAlphaNumeric As String
  5.        Static strPanelInfo As String
  6.  
  7.        If strAlphaNumeric = strLastAlphaNumeric Then
  8.             strPanelInfo = strPanelInfo & ", " & strWallMark# 
  9.       Else
  10.            strLastAlphaNumeric = strAlphaNumeric
  11.            strPanelInfo = strWallMark#
  12.        End If
  13.        CONCAT = strPanelInfo
  14.  
  15. End Function
Jan 28 '08 #7
NeoPa
32,556 Expert Mod 16PB
# is a special character in names that forces the variable to be of a particular type. I forget which '#' is, but the character for String is '$'. It is not valid to use these characters in names otherwise. My system's down at the moment (just going) so I can't find which '#' is now. I may find it later and post again.
Jan 28 '08 #8
NeoPa
32,556 Expert Mod 16PB
From http://support.microsoft.com/kb/q191713/ I got :
Expand|Select|Wrap|Line Numbers
  1. Char  Type
  2.  %    Integer
  3.  &    Long
  4.  !    Single
  5.  #    Double
  6.  $    String
  7.  @    Currency
Jan 28 '08 #9

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

Similar topics

1
by: Valerie | last post by:
Hi everyone, I really appreciate if anyone could help me with this tricky problem that I'm having. I'm looking for a sample script to combine data in multiple rows into one row. I'm using...
4
by: Iprogramforlawyers | last post by:
I need to take any amount of rows and turn them into one single row. I'm exporting some data from sql. The program its going into only has one note field. I've used UNION and those types of...
9
by: kencana | last post by:
Hi all, I am a new bie in SOAP and PHP.I got one question about the data retrieval. I am able to retrieve the data successfully from my database. this is my sql statement: select roadname from...
7
by: Mintyman | last post by:
Hi, I'm working on a system migration and I need to combine data from multiple rows (with the same ID) into one comma separated string. This is how the data is at the moment: Company_ID ...
1
by: Sanjaylml | last post by:
I have a form through which, e-mail address of parties are showing through datasheet mode. Is their any way to club the data of multiple rows in one column? Like : ajaimathur@rediffmail.com...
1
by: boss1 | last post by:
i m having problem with inserting data into oracle db using php. i need to how to fetch fetch multiple row's data from a table in html form and insert into oracle db at a time. may be looping is...
2
by: kagweh | last post by:
Am new to Access so go easy Each serial number has several comments made for it and what I need is to combine all comments for each serial into one row separated by a comma or l. Now here are...
3
by: klbachrodt | last post by:
Hi all - I've been browsing this forum for a while now, looking for help, and finally decided to join and ask my question, since I'm not terribly good at writing SQL queries in Access. Here is my...
10
aas4mis
by: aas4mis | last post by:
I have a table with a deviceid, attribute type, and attribute value. There are many attributes for a single device id. I want my query to retrieve a single device id with multiple attribute values....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.