473,385 Members | 1,342 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,385 software developers and data experts.

Getting a report from a table

Shakss2
19
Hello all,

I have a table name "info" which looks like,

ProjectID Consultantname
1 Alpha
1 Beta
1 Charlie
2 James
2 Mario
3 Shak

Now im getting a excel report in the below format.

ProjectID Consultantname
1 Alpha
1 Beta
1 Charlie
2 James
2 Mario
3 Shak

I want a excel report which gives the result as below:

ProjectID Consultantname
1 Alpha, Beta, Charlie
2 James, Mario
3 Shak

im struck here n cant proceed further.
Pls help

Thanks,
Shaq
Jan 17 '08 #1
4 1234
ADezii
8,834 Expert 8TB
Hello all,

I have a table name "info" which looks like,

ProjectID Consultantname
1 Alpha
1 Beta
1 Charlie
2 James
2 Mario
3 Shak

Now im getting a excel report in the below format.

ProjectID Consultantname
1 Alpha
1 Beta
1 Charlie
2 James
2 Mario
3 Shak

I want a excel report which gives the result as below:

ProjectID Consultantname
1 Alpha, Beta, Charlie
2 James, Mario
3 Shak

im struck here n cant proceed further.
Pls help

Thanks,
Shaq
Just subscribing, I'll have your answer either this afternoon or this evening if no one gets to it before me.
Jan 17 '08 #2
ADezii
8,834 Expert 8TB
Hello all,

I have a table name "info" which looks like,

ProjectID Consultantname
1 Alpha
1 Beta
1 Charlie
2 James
2 Mario
3 Shak

Now im getting a excel report in the below format.

ProjectID Consultantname
1 Alpha
1 Beta
1 Charlie
2 James
2 Mario
3 Shak

I want a excel report which gives the result as below:

ProjectID Consultantname
1 Alpha, Beta, Charlie
2 James, Mario
3 Shak

im struck here n cant proceed further.
Pls help

Thanks,
Shaq
  1. Create a Table named tblResults. This Table will consist of only 2 Fields with no Primary Key:
    1. [ProjectID] - [NUMBER] {LONG}
    2. [Consultant(s)] - [TEXT 255]
  2. Copy and Paste, then Run the following code from anywhere you like:
    Expand|Select|Wrap|Line Numbers
    1. Dim MyDB As DAO.Database, MyRS_ID As DAO.Recordset, strSQL As String
    2. Dim MyRS_Info As DAO.Recordset, strInfo As String, rstResults As DAO.Recordset
    3. Dim strRestrictID As String, strConsultants As String
    4.  
    5. 'DELETE any pre-existing Records in tblResults
    6. DoCmd.SetWarnings False
    7.   DoCmd.RunSQL "DELETE * From tblResults;"
    8. DoCmd.SetWarnings False
    9.  
    10.  
    11. 'Get a listing of Unique ProjectIDs
    12. strSQL = "SELECT Distinct [ProjectID] From Info Order By [ProjectID];"
    13. strInfo = "Select * From Info;":
    14.  
    15. Set MyDB = CurrentDb()
    16. Set MyRS_ID = MyDB.OpenRecordset(strSQL, dbOpenSnapshot)
    17. Set rstResults = MyDB.OpenRecordset("tblResults", dbOpenDynaset)
    18.  
    19. Do While Not MyRS_ID.EOF
    20.  strRestrictID = "SELECT * From Info Where [ProjectID] =" & MyRS_ID![ProjectID]
    21.  Set MyRS_Info = MyDB.OpenRecordset(strRestrictID, dbOpenSnapshot)
    22.   Do While Not MyRS_Info.EOF
    23.     strConsultants = strConsultants & MyRS_Info!ConsultantName & ","
    24.     MyRS_Info.MoveNext
    25.   Loop
    26.     strConsultants = Left(strConsultants, Len(strConsultants) - 1)
    27.       rstResults.AddNew
    28.         rstResults![ProjectID] = MyRS_ID![ProjectID]
    29.         rstResults![Consultant(s)] = strConsultants
    30.       rstResults.Update
    31.       strConsultants = ""     'Reset
    32.   MyRS_Info.MoveFirst
    33.   MyRS_ID.MoveNext
    34. Loop
    35.  
    36. MyRS_ID.Close: Set MyRS_ID = Nothing
    37. rstResults.Close: Set rstResults = Nothing
    38. MyRS_Info.Close: Set MyRS_Info = Nothing
  3. The data that you requested, in the proper format, will now be contained in tblResults in Ascending ProjectID Order. Since the data is contained within a Table, you can do virtually anything you like with it.
Jan 17 '08 #3
Shakss2
19
Thanks a lot, that works...

But im having another issue.. which looks similar but a bit messed up.

I have a table as below

ProjID b c d e f
2 12 3 1 2 1
3 10 3 0 2 4
4 5 5 6 5 5
5 4 2 0 0 0
6 1 0 0 1 0
8 0 6 0 7 2
10 0 0 0 0 0

I want a o/p in excel like below...

1st column projID
2nd column should be like this:
b, 12,
c, 3,
d, 1,
e, 2,
f, 1 (in one cell)
like previously we got all Consultants in one cell.

If U can help with this.. I will run short of words to thank :)

Shaq
Jan 18 '08 #4
Shakss2
19
I got it working... :)

Thanks for helping me with the 1st result.

Regards,
Shaq
Jan 28 '08 #5

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

Similar topics

15
by: U N Me | last post by:
I have a continuous form that lists records from a query. One of the columns is an amount field, In the footer of the form I place a text box that displays the total (sum) of the amount. The...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
5
by: Greg Teets | last post by:
I am running an Access report from VB via ADO. The report has a field that shows the date it was run. How can I return the data from this field to VB or have Access post it to a table when the...
1
by: kkrizl | last post by:
I have a form that displays general information about an alarm permit location. There's a subform that shows detailed information about burglar alarms that have gone off at the location. When a...
8
by: Brent White | last post by:
If you need more information, I'd be glad to give it, but I am developing an ASPX page so that the user can select multiple values for a specific field, then pass them on (using Crystal Reports 10...
0
by: Spacy | last post by:
Please help me! I have tried all options. Nothing works! I have 2 hyperlinks, Report1 & Report2. On click of Report1, a html table (report) is being displayed on a child frame. On this child...
4
by: devi | last post by:
Hi, In oracle I have a LAG function using which I could get the previous value of a field. Do we have anything similar to that in SQL Server or access? Thanks Devi
6
by: Uday | last post by:
Hi everyone, I have a ASP page that triggers a db-side stored procedure. At the end of the procedure, it spits out a log file, that this ASP page reads and displays for the users. But the...
11
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.