Solved

VB6 Data Report with code

Posted on 2000-03-25
16
432 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
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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

932 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

13 Experts available now in Live!

Get 1:1 Help Now