• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 485
  • Last Modified:

VB6 Data Report with code

Well i am working with data reports using Visual Basic 6, but with codes instead of data environment.  my problem now is am trying to make the report master/detail one but am having difficulties in coding. The code i wrote for the report will execute all the data which will be duplicated, what i mean is; if i have a person's name, and working times, it will represent the name again and again with eaching working times, what i need is to represent the name once only for his/her list of working times.....(by the way am using MS Access)

The code to put data into report:

With DR /*DR is the report name*/
   .Hide
   Set .DataSource = rs /*Dim rs As New ADODB.Recordset*/
   .DataMember = ""
   With .Sections("Section1").Controls
       For intCtrl = 1 To .Count
     If TypeOf .Item(intCtrl) Is RptLabel Then
                .Item(intCtrl).Caption = rs.Fields(q).Name & ":"
                 q = q + 1
            End If
            If TypeOf .Item(intCtrl) Is RptTextBox Then
                .Item(intCtrl).DataMember = ""
                .Item(intCtrl).DataField = rs(z).Name
                z = z + 1
            End If
    Next intCtrl
   End With
   .Refresh
   .Show
   End With

Can sombody help me????
0
aboura
Asked:
aboura
  • 9
  • 2
  • 2
  • +3
1 Solution
 
vbbuffCommented:
Hi,
  It will be more easy if you just give what code you are using.
 
  By what you have given, I think if you use a SQL statement like:

  "Select * From MasterTable Group By PersonName"

  This is just an idea. If  you give your code may be i could give suggestion
0
 
soosairajCommented:
Hi..

  Use Group by function in your query.
for example..  just grup by person name.  in that case.. in report itself Personname grup header also will create. then put Person name In group header..and put workingtime in detail section..

Regards..
Raj
0
 
abouraAuthor Commented:
Adjusted points from 35 to 40
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
abouraAuthor Commented:
well guys do you think it will work by using two dimensional arrays to represent the report correctly??....please its urgent....
i tried mostly every thing i know but nothing worked......
0
 
jntj405Commented:
Use another tool such as Crystal Reports, to make your reports. It has more possibilities, such as subreports. In these subreports you can show the detail-records.
0
 
abouraAuthor Commented:
Adjusted points from 40 to 45
0
 
abouraAuthor Commented:
Do u think i can use Crystal Reports with VB6??? and how would i?????
0
 
jntj405Commented:
Yes, you can start crystal reports from vb6. You must set a link to the component 'Crystal Report Control' in VB6. Then you can call the report by:

Private Sub cmdPrint_Click(Index As Integer)
    'This procedure handles the printing of the report
   
    FprSetParameters
    Select Case Index
        Case 0
            CRReport.Destination = crptToPrinter
        Case 1
            CRReport.Destination = crptToWindow
    End Select
    CRReport.PrintReport
End Sub

Private Sub FprSetParameters()
    CRReport.ReportFileName = App.Path & "\Reports\Person.rpt"
   
    If chkGeneralInfo = 0 Then
        CRReport.ParameterFields(0) = "GeneralInfo;False;True"
    Else
        CRReport.ParameterFields(0) = "GeneralInfo;True;True"
    End If
   
    CRReport.SQLQuery = "SELECT * From Tabel1 Where Id=" & DE.rs1("Id")
End Sub

The SQLQuery-property may be changed, but only the where-stat may be!

Via the parameterfields you can give extra data (ex. selection criteria) to crystal.
0
 
abouraAuthor Commented:
The Crystal Reports in the vb does not work...!!???
0
 
abouraAuthor Commented:
Adjusted points from 45 to 50
0
 
abouraAuthor Commented:
Adjusted points from 50 to 60
0
 
rovermCommented:
aboura, If I understand your problem correct you want to group names and their details in a datareport.

To do this you can use grouping:
Make a command in the DataEnvironment and goto the tab grouping.
Then select the Name-fields (these are the field the datareport will group e.g. group on).

Then insert a Group Header/Footer on the DataReport.
Set the DataMember property to 'command GROUPING ...' .
Place the name fields in the group header and the detail fields in the details section.

Good luck !

D'Mzzl!
RoverM
0
 
abouraAuthor Commented:
RoverM, yes i want to group names, but i'm  not using Data Environment, am using a code to put the fields in the report....i mean this code works with a simple report, but i couldn't make it possible with master detail grouping...so do you have any hints on how to perform it?
0
 
abouraAuthor Commented:
Adjusted points from 60 to 70
0
 
rovermCommented:
Okay, what I did in a situation like this is to fill a 'dummy'-table with all the data filtered in the way I wanted to present it.
Then connect the DataReport to it and go !

Good luck!
D'Mzzl!
RoverM
0
 
javierv1Commented:
Hi, I would like to know how I can fill a dummy table and how to connect the data report to it.
Can anybody help me because I have exactly the same problem? By the way, this is the only answer that I've found to this question.
Thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now