|
-
Oct 11th, 2006, 04:22 AM
#1
Thread Starter
Addicted Member
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?
-
Oct 11th, 2006, 04:27 AM
#2
Re: Data Report
 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
-
Oct 11th, 2006, 04:29 AM
#3
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.
-
Oct 11th, 2006, 04:31 AM
#4
Re: Data Report
 Originally Posted by shakti5385
Why not using the distinct in the sql query 
Because the records (when all fields are compared) are already distinct
-
Oct 11th, 2006, 04:33 AM
#5
Re: Data Report
 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
-
Oct 11th, 2006, 04:40 AM
#6
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.
-
Oct 11th, 2006, 04:45 AM
#7
Junior Member
Re: Data Report
possible to use GROUP BY ??
-
Oct 11th, 2006, 04:47 AM
#8
Re: Data Report
 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:
Private Sub CREPORT_Click()
On Error GoTo ErrorTrap
TSQL = ""
TSQL = "SELECT * FROM LEAVE_TABLE WHERE FIRM='" & COMFIRMNAME.Text & "' AND S_DATE BETWEEN #" & DTP1.Value & "# and #" & DTP2.Value & "#"
Set RTMP = Get_Special_Record_Set(TSQL)
If RTMP.RecordCount = 0 Then
MsgBox "Record Not Found", vbInformation
Exit Sub
End If
With FIRM_STATUS
Set .DataSource = Nothing
Set .DataSource = RTMP.DataSource
End With
'firm status is datareport name
'don't forget to write all control in section 1 of your report
'coding by banna
With FIRM_STATUS.Sections("Section1").Controls
.Item("LD1").Caption = DTP1.Value
'label first name ld1
.Item("LD2").Caption = DTP2.Value
'label second name ld2
.Item("TXTFIRM").DataMember = ""
.Item("TXTFIRM").DataField = RTMP.Fields("FIRM").Name
'textbox first name txtfirm
'firm is field firm in the table
.Item("TXTLOCATION").DataMember = ""
.Item("TXTLOCATION").DataField = RTMP.Fields("LOCATION").Name
'txtbox second name txtlocation
'location is field location in the table
.Item("LABNOEMP").Caption = EMP
'label third name labnoemp
.Item("LSALARY").Caption = Val(SALARY)
'label lsalary name lsalary
End With
FIRM_STATUS.Refresh
'firm_status is datareport name
FIRM_STATUS.Show
ErrorTrap:
If Err.Number <> 0 Then
MsgBox "Error (" & Err.Number & "): " & Err.Description, vbCritical, "Error"
End If
End Sub
-
Oct 11th, 2006, 04:49 AM
#9
Re: Data Report
 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.
-
Oct 11th, 2006, 04:53 AM
#10
Re: Data Report
 Originally Posted by shakti5385
See the code just example you can use the distinct in the query
VB Code:
Private Sub CREPORT_Click()
On Error GoTo ErrorTrap
TSQL = ""
TSQL = "SELECT * FROM LEAVE_TABLE WHERE FIRM='" & COMFIRMNAME.Text & "' AND S_DATE BETWEEN #" & DTP1.Value & "# and #" & DTP2.Value & "#"
Set RTMP = Get_Special_Record_Set(TSQL)
If RTMP.RecordCount = 0 Then
MsgBox "Record Not Found", vbInformation
Exit Sub
End If
With FIRM_STATUS
Set .DataSource = Nothing
Set .DataSource = RTMP.DataSource
End With
'firm status is datareport name
'don't forget to write all control in section 1 of your report
'coding by banna
With FIRM_STATUS.Sections("Section1").Controls
.Item("LD1").Caption = DTP1.Value
'label first name ld1
.Item("LD2").Caption = DTP2.Value
'label second name ld2
.Item("TXTFIRM").DataMember = ""
.Item("TXTFIRM").DataField = RTMP.Fields("FIRM").Name
'textbox first name txtfirm
'firm is field firm in the table
.Item("TXTLOCATION").DataMember = ""
.Item("TXTLOCATION").DataField = RTMP.Fields("LOCATION").Name
'txtbox second name txtlocation
'location is field location in the table
.Item("LABNOEMP").Caption = EMP
'label third name labnoemp
.Item("LSALARY").Caption = Val(SALARY)
'label lsalary name lsalary
End With
FIRM_STATUS.Refresh
'firm_status is datareport name
FIRM_STATUS.Show
ErrorTrap:
If Err.Number <> 0 Then
MsgBox "Error (" & Err.Number & "): " & Err.Description, vbCritical, "Error"
End If
End Sub
I don't see a distinct keyword in your query.
-
Oct 11th, 2006, 04:54 AM
#11
Thread Starter
Addicted Member
Re: Data Report
Thanks for ur replies. Can u explain how to make group1 & 2.
My code :
VB Code:
Private Sub cmdOk_Click()
On Error Resume Next
If txtCode = "" Then
flag = MsgBox("Display Entire Return Report?", vbYesNo + vbQuestion, "Smart Billing")
If flag = vbYes Then
If Rs.State = adStateOpen Then
Rs.Close
End If
Rs.open "Select * from checknew", conn
Set returnnoReport.DataSource = Rs
Load returnnoReport
returnnoReport.Show
Unload Me
Else
Exit Sub
Txtdate.SetFocus
End If
Else
If Rs.State = adStateOpen Then
Rs.Close
End If
Rs.open "select * from checknew where badgeno= " & txtCode.Text, conn
Set returnnoReport.DataSource = Rs
Load returndateReport
returnnoReport.Show
Unload Me
End If
End Sub
-
Oct 11th, 2006, 04:56 AM
#12
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)
-
Oct 11th, 2006, 04:59 AM
#13
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.
-
Oct 11th, 2006, 05:00 AM
#14
Re: Data Report
 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
-
Oct 11th, 2006, 05:07 AM
#15
Thread Starter
Addicted Member
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.
-
Oct 11th, 2006, 05:21 AM
#16
Re: Data Report
 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
-
Oct 11th, 2006, 10:51 AM
#17
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.
-
Oct 11th, 2006, 11:37 AM
#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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|