Results 1 to 18 of 18

Thread: Data Report

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    169

    Data Report

    I have a report that displays all the information about employees.
    Some fields,I don't want to display repeatedly.
    For ex,

    Empno,Grade.
    Now it displays like:

    Empno Grade Name Item Received
    111 Er xyz frt
    111 Er xyz efg

    Any option is there not to display those fields repeatedly.
    Please help me?

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: Data Report

    Quote Originally Posted by Akshaya
    I have a report that displays all the information about employees.
    Any option is there not to display those fields repeatedly.
    Please help me?
    Why not using the distinct in the sql query

  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Data Report

    You need to either (1) create a heirarchical recordset with a shape query or (2) create a heirarchy of command objects in the dataenvironment GUI. When you have the heirarchy then you create groups/sections in your report. The innermost group will contain the repeating data "xyz frt", for "111 Er"you place those in the higher level group.
    Last edited by leinad31; Oct 11th, 2006 at 04:35 AM.

  4. #4
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Data Report

    Quote Originally Posted by shakti5385
    Why not using the distinct in the sql query
    Because the records (when all fields are compared) are already distinct

  5. #5
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: Data Report

    Quote Originally Posted by leinad31
    Because the records (when all fields are compared) are already distinct
    Empno Grade Name Item Received
    111 Er xyz frt
    111 Er xyz efg
    Same employee number 2 times how it is distinct

  6. #6
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Data Report

    The records are distinct cause not all columns are the same, only two columns. He needs to show those 2 records in the report..

    He can't accomplish this with just one SELECT query, even with distinct, plain and simple... he needs two queries related in a SHAPE query, or create a heirarchy of command objects (each with its own select query). Your DISTINCT solution is applicable only to the first recordset in the heirarchy (which returns just the first two columns).

    For each page you create subgroups
    111 Er repeats in group1 (or labels are placed in the page section group1)
    xyz frt and xyz efg repeats in group2 which is contained in group1 (or labels are placed in section group2 which is under page section group1)
    Last edited by leinad31; Oct 11th, 2006 at 04:46 AM.

  7. #7
    Junior Member
    Join Date
    Oct 2006
    Posts
    29

    Re: Data Report

    possible to use GROUP BY ??

  8. #8
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: Data Report

    Quote Originally Posted by leinad31
    The records are distinct cause not all columns are the same, only two columns. He needs to show those 2 records in the report..

    in group1 (or labels are placed in section group2 which is under page section group1)
    See the code just example you can use the distinct in the query
    VB Code:
    1. Private Sub CREPORT_Click()
    2. On Error GoTo ErrorTrap
    3.  
    4. TSQL = ""
    5. TSQL = "SELECT * FROM LEAVE_TABLE WHERE FIRM='" & COMFIRMNAME.Text & "' AND S_DATE BETWEEN #" & DTP1.Value & "# and #" & DTP2.Value & "#"
    6. Set RTMP = Get_Special_Record_Set(TSQL)
    7.  
    8. If RTMP.RecordCount = 0 Then
    9. MsgBox "Record Not Found", vbInformation
    10. Exit Sub
    11. End If
    12.  
    13.  
    14. With FIRM_STATUS
    15.     Set .DataSource = Nothing
    16.     Set .DataSource = RTMP.DataSource
    17. End With
    18. 'firm status is datareport name
    19. 'don't forget to write all control in section 1 of your report
    20. 'coding by banna
    21. With FIRM_STATUS.Sections("Section1").Controls
    22.    
    23.     .Item("LD1").Caption = DTP1.Value
    24.     'label first name ld1
    25.     .Item("LD2").Caption = DTP2.Value
    26.     'label second name ld2
    27.     .Item("TXTFIRM").DataMember = ""
    28.     .Item("TXTFIRM").DataField = RTMP.Fields("FIRM").Name
    29.     'textbox first name txtfirm
    30.     'firm is field firm in the table
    31.     .Item("TXTLOCATION").DataMember = ""
    32.     .Item("TXTLOCATION").DataField = RTMP.Fields("LOCATION").Name
    33.     'txtbox second name txtlocation
    34.     'location is field location in the table
    35.     .Item("LABNOEMP").Caption = EMP
    36.     'label third name labnoemp
    37.     .Item("LSALARY").Caption = Val(SALARY)
    38.     'label lsalary name lsalary
    39. End With
    40. FIRM_STATUS.Refresh
    41. 'firm_status is datareport name
    42.  
    43. FIRM_STATUS.Show
    44. ErrorTrap:
    45. If Err.Number <> 0 Then
    46.    MsgBox "Error (" & Err.Number & "): " & Err.Description, vbCritical, "Error"
    47. End If
    48. End Sub

  9. #9
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Data Report

    Quote Originally Posted by irene casper
    possible to use GROUP BY ??
    I don't think he is using aggregate functions such as Sum()... and the end result would be something similar to DISTINCT.

  10. #10
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Data Report

    Quote Originally Posted by shakti5385
    See the code just example you can use the distinct in the query
    VB Code:
    1. Private Sub CREPORT_Click()
    2. On Error GoTo ErrorTrap
    3.  
    4. TSQL = ""
    5. TSQL = "SELECT * FROM LEAVE_TABLE WHERE FIRM='" & COMFIRMNAME.Text & "' AND S_DATE BETWEEN #" & DTP1.Value & "# and #" & DTP2.Value & "#"
    6. Set RTMP = Get_Special_Record_Set(TSQL)
    7.  
    8. If RTMP.RecordCount = 0 Then
    9. MsgBox "Record Not Found", vbInformation
    10. Exit Sub
    11. End If
    12.  
    13.  
    14. With FIRM_STATUS
    15.     Set .DataSource = Nothing
    16.     Set .DataSource = RTMP.DataSource
    17. End With
    18. 'firm status is datareport name
    19. 'don't forget to write all control in section 1 of your report
    20. 'coding by banna
    21. With FIRM_STATUS.Sections("Section1").Controls
    22.    
    23.     .Item("LD1").Caption = DTP1.Value
    24.     'label first name ld1
    25.     .Item("LD2").Caption = DTP2.Value
    26.     'label second name ld2
    27.     .Item("TXTFIRM").DataMember = ""
    28.     .Item("TXTFIRM").DataField = RTMP.Fields("FIRM").Name
    29.     'textbox first name txtfirm
    30.     'firm is field firm in the table
    31.     .Item("TXTLOCATION").DataMember = ""
    32.     .Item("TXTLOCATION").DataField = RTMP.Fields("LOCATION").Name
    33.     'txtbox second name txtlocation
    34.     'location is field location in the table
    35.     .Item("LABNOEMP").Caption = EMP
    36.     'label third name labnoemp
    37.     .Item("LSALARY").Caption = Val(SALARY)
    38.     'label lsalary name lsalary
    39. End With
    40. FIRM_STATUS.Refresh
    41. 'firm_status is datareport name
    42.  
    43. FIRM_STATUS.Show
    44. ErrorTrap:
    45. If Err.Number <> 0 Then
    46.    MsgBox "Error (" & Err.Number & "): " & Err.Description, vbCritical, "Error"
    47. End If
    48. End Sub
    I don't see a distinct keyword in your query.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    169

    Re: Data Report

    Thanks for ur replies. Can u explain how to make group1 & 2.
    My code :

    VB Code:
    1. Private Sub cmdOk_Click()
    2.     On Error Resume Next
    3.     If txtCode = "" Then
    4.         flag = MsgBox("Display Entire Return Report?", vbYesNo + vbQuestion, "Smart Billing")
    5.         If flag = vbYes Then
    6.             If Rs.State = adStateOpen Then
    7.                 Rs.Close
    8.             End If
    9.             Rs.open "Select * from checknew", conn
    10.             Set returnnoReport.DataSource = Rs
    11.             Load returnnoReport
    12.             returnnoReport.Show
    13.             Unload Me
    14.         Else
    15.             Exit Sub
    16.             Txtdate.SetFocus
    17.         End If
    18.     Else
    19.         If Rs.State = adStateOpen Then
    20.             Rs.Close
    21.         End If
    22.         Rs.open "select * from checknew where badgeno= " & txtCode.Text, conn
    23.         Set returnnoReport.DataSource = Rs
    24.         Load returndateReport
    25.         returnnoReport.Show
    26.         Unload Me
    27.     End If
    28. End Sub

  12. #12
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Data Report

    shakti, have you even ever tried making a datareport with nested sections? If not, then that explains why your not getting my point.

    For each page you create subgroups
    111 Er repeats in group1 (or labels are placed in the page section group1)
    xyz frt and xyz efg repeats in group2 which is contained in group1 (or labels are placed in section group2 which is under page section group1)

  13. #13
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Data Report

    Unfortunately, I'm on a public PC with no VB IDE cause my PC won't boot. But I'm sure someone can give you a sample using SHAPE query cause you did this.

    Rs.open "Select * from checknew", conn
    Set returnnoReport.DataSource = Rs

    Best if you posted relevant table structure and how the tables are related (on which fields) to facilitate creation of the query.

  14. #14
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: Data Report

    Quote Originally Posted by leinad31
    shakti, have you even ever tried making a datareport with nested sections? If not, then that explains why your not getting my point.
    It was past now i not use data report related to my example it was just a demo i tell that you can use the distinct for selecting the field

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    169

    Re: Data Report

    Table Structure(checknew)

    Empcode-----N
    Empname-----T
    Grade--------T
    Itemname----T
    Date---------T
    qty----------N

    Empcode,Empname and Grade Should be displayed once.

  16. #16
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: Data Report

    Quote Originally Posted by Akshaya
    Table Structure(checknew)

    Empcode,Empname and Grade Should be displayed once.
    Hi did u have crystal report on ur pC just asking

  17. #17
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Data Report

    someone can give you a sample using SHAPE query cause you did this.
    You must open the ADO Connection object using the MSDataShape provider and include a Data Provider argument.

    Dim cnn As New ADODB.Connection
    cnn.Open "provider=msdatashape;data provider=SQLOLEDB...

    Does the table have a primary key? You need to link the child command to the header command via the Relate clause. Usually done with the Primary Key. Just make sure the PK is in the Selection List of both Commands.

    strSQL = "Shape {Select EmpCode, EmpName, Grade From CheckNew}
    Append ({Select * From CheckNew}
    Relate EmpName To EmpName) As Details"

    As for the Data Report, set the Data Member and Data Field properties for anything in the Details section. Data Member is the name given to the Child command (in this case also called Details).
    Last edited by brucevde; Oct 11th, 2006 at 10:58 AM.

  18. #18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width