Solved

VB6 Data Report with code

Posted on 2000-03-25
16
422 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
  • 9
  • 2
  • 2
  • +3
16 Comments
 
LVL 3

Expert Comment

by:vbbuff
Comment Utility
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
Comment Utility
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
Comment Utility
Adjusted points from 35 to 40
0
 

Author Comment

by:aboura
Comment Utility
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
Comment Utility
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
Comment Utility
Adjusted points from 40 to 45
0
 

Author Comment

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

Expert Comment

by:jntj405
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

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

Author Comment

by:aboura
Comment Utility
Adjusted points from 45 to 50
0
 

Author Comment

by:aboura
Comment Utility
Adjusted points from 50 to 60
0
 
LVL 12

Expert Comment

by:roverm
Comment Utility
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
Comment Utility
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
Comment Utility
Adjusted points from 60 to 70
0
 
LVL 12

Accepted Solution

by:
roverm earned 70 total points
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now