473,585 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting a report from a table

Shakss2
19 New Member
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 1245
ADezii
8,834 Recognized Expert Expert
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 Recognized Expert Expert
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 New Member
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 New Member
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
7959
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 data in the form is linked from a one-to-many table relationship. In this instance, I really can't sum the value from the one's table since if there...
1
17652
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 Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
5
1804
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 report runs? Thank you. Greg Teets
1
2688
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 new alarm is entered on the subform, I want to print a report that shows the general information and the alarms that were entered. The record source...
8
1803
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 on a separate ASP page). Here is the code behind the button that will launch the report (is in a file called StateSelect.aspx.vb: Protected Sub...
0
1062
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 page i have a link "Export to Excel", on the click of which the report is getting saved in excel. The code is: Response.ContentType =...
4
4143
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
1947
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 problem is that the database-stored Proc could take anything between 10 secs - to - 10 mins. I dont want the page to time out . Is there a way, like the...
11
7303
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 is run again? This is causing certain error problems. 1 Why does the code run for a print preview when the report already exists? 2 What...
0
7908
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...
0
8199
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. ...
0
8336
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8212
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...
1
5710
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...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2343
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1175
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...

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.