Solved

VB6 Data Report with code

Posted on 2000-03-25
16
458 Views
Last Modified: 2013-12-25
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
Comment
Question by:aboura
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 2
  • 2
  • +3
16 Comments
 
LVL 3

Expert Comment

by:vbbuff
ID: 2657828
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
 

Expert Comment

by:soosairaj
ID: 2657903
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
 

Author Comment

by:aboura
ID: 2659473
Adjusted points from 35 to 40
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

by:aboura
ID: 2666088
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
 

Expert Comment

by:jntj405
ID: 2666179
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
 

Author Comment

by:aboura
ID: 2667852
Adjusted points from 40 to 45
0
 

Author Comment

by:aboura
ID: 2667853
Do u think i can use Crystal Reports with VB6??? and how would i?????
0
 

Expert Comment

by:jntj405
ID: 2668263
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
 

Author Comment

by:aboura
ID: 2677101
The Crystal Reports in the vb does not work...!!???
0
 

Author Comment

by:aboura
ID: 2682611
Adjusted points from 45 to 50
0
 

Author Comment

by:aboura
ID: 2702820
Adjusted points from 50 to 60
0
 
LVL 12

Expert Comment

by:roverm
ID: 2726140
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
 

Author Comment

by:aboura
ID: 2729317
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
 

Author Comment

by:aboura
ID: 2741096
Adjusted points from 60 to 70
0
 
LVL 12

Accepted Solution

by:
roverm earned 70 total points
ID: 2754263
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
 

Expert Comment

by:javierv1
ID: 5660669
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
passing a value with stream reader AFTER a ";" 3 90
Add and format columns in vb6 7 82
Passing a Text Box name to a Sub 6 104
Problem to With line 4 85
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question