CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2002
    Location
    Pakistan
    Posts
    114

    Very Urgent, Please Help !

    Hello There,

    I want to generate Report using VB's DataReport without using Data Environment. I also want to parameterized the DataReport.
    In oher words, How can I change query of DataReport to generate different reults at runtime.
    Please, Help.
    Älwäÿ§ T®ü§t ¥öü® §ëlf , Nöt Öthë®§

  2. #2
    Join Date
    Jan 2003
    Posts
    4

    Thumbs down One Suggestion

    Visual Basic Data report was a thegreatest failure from Microsoft, I have wasted days and days to get what I want but still

    Better try out Crystal Reports that is rich in options.


    Sorry that my question could not help you specifically in your problem.

  3. #3
    Join Date
    Dec 2002
    Location
    Pakistan
    Posts
    114
    Hello,
    Don't worry malikware I have been working almost constantly since I posted my question about data report. Fortunately, I have come up with a lot more information about it and have successfully implemented my solution using Data Report. I think it is not much tedious task to use them.
    Now I am postin gthis reply only for you after I read your reply. If you want some help in this regard, I mean, about Data Report Control, then perhaps I could make my share.

    Best of Luck.
    neagle.
    Älwäÿ§ T®ü§t ¥öü® §ëlf , Nöt Öthë®§

  4. #4
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    Or....you could post your solution here so we could all learn from you.

    My thoughts are that if you ask for assistance, and people take the time to try to help, then if you find the solution on your own, you should post the solution to assist others in the future. If everybody kept the code and solutions to themselves, then forums like this wouldn't exist!!!!!!

  5. #5
    Join Date
    Jan 2003
    Location
    malaysia
    Posts
    5

    Exclamation

    maybe u can try this...hope this will help u

    Dim rptdb As New ADODB.Recordset
    Set rptdb = New ADODB.Recordset

    SQL = "select * from table_name where data_field='" & your_object & "'"

    With rptdb

    .Source = SQL
    .Open , SPR, adOpenKeyset, adLockPessimistic, adCmdText

    If .RecordCount <= 0 Then

    MsgBox "No Data were found", vbOKOnly + vbInformation
    Else
    Set DataReport1.DataSource = rptdb
    DataReport1.Show
    End If

    End With

  6. #6
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    This might help - parameterized queries & how to do it.

  7. #7
    Join Date
    Dec 2002
    Location
    Pakistan
    Posts
    114
    Hello there,
    Twodogs you are absolutely right and I appriciate your comments.
    Following is the solution which is found by me on my own:

    Code:
    Dim Con As New Connection
    Dim Rs As New Recordset
    
    If Not (varGoldClass.initDB(Con)) Then
        GoTo Handler
    End If
    
    Rs.Open "Select REPORT.RefNo,REPORT.Date,REPORT.OrnamentTypes,REPORT.GoldPromissedDate,REPORT.DispatchDate,REPORT.Dispatched from REPORT Where REPORT.Type='ADVANCE' AND REPORT.Date>=#" & frmShowTransInfo.dtStart.Value & "# AND REPORT.Date<=#" & frmShowTransInfo.dtEnd.Value & "#", Con, adOpenDynamic, adLockOptimistic
    On Error GoTo Handler
        If Not (Rs.EOF) Then
            With drDispOrders
                Set .DataSource = Rs: .DataMember = ""
                .Hide
                With .Sections("secBodyAdv").Controls
                        '---RefNo----
                    .Item(1).DataMember = ""
                    .Item(1).DataField = Rs("RefNo").Name
                        '---Date---
                    .Item(2).DataMember = ""
                    .Item(2).DataField = Rs("Date").Name
                        '---Ornament---
                    .Item(3).DataMember = ""
                    .Item(3).DataField = Rs("OrnamentTypes").Name
                        '---Promiss---
                    .Item(4).DataMember = ""
                    .Item(4).DataField = Rs("GoldPromissedDate").Name
                        '---DispatchDate---
                    .Item(5).DataMember = ""
                    .Item(5).DataField = Rs("DispatchDate").Name
                        '---Dispatched---
                    .Item(6).DataMember = ""
                    .Item(6).DataField = Rs("Dispatched").Name
                                  
                    
                End With
                            
                '----------------------------------------------
               
               .Refresh
               .Show
            End With
            
        Else
            MsgBox "No Records exist under given time period", vbInformation + vbOKOnly + vbApplicationModal, "Gold Soft 2003"
            Exit Sub
        End If
        
        Rs.Close: Con.Close
        Set Rs = Nothing: Set Con = Nothing
        Exit Sub
        
    Handler:
        MsgBox "Unexpected Error Occured during Report building", vbCritical + vbOKOnly + vbApplicationModal, "Gold Soft 2003"
    End Sub
    The above code generates a totally dynamic report by setting various fields accordingly. and yes ofcourse you can write full Name of the control like "txtFirst" or "lblEnd" etc. in place of .item(1).

    In the last I would like to thank you for your help on how to get Parameterized query Report.

    Anyhow, Can you tell me if it is possibile to add dynamic controls to Data Reports, Imean using any or same method like "Controls.Add".
    Älwäÿ§ T®ü§t ¥öü® §ëlf , Nöt Öthë®§

  8. #8
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    I haven't tried it with data reports, but I've put some code up here in the past dealing with dynamic controls - if you do a search you should be able to find them.

    Thanks for posting your solution - it looks good

  9. #9
    Join Date
    Dec 2002
    Location
    Pakistan
    Posts
    114
    Hello there,

    Thank you TwoHogs, but I have searched for it but can't find a way till now to add controls dynamically to Data Reports.
    If you find then please, Post it to me.

    Thanks.
    Älwäÿ§ T®ü§t ¥öü® §ëlf , Nöt Öthë®§

  10. #10
    Join Date
    Oct 2001
    Posts
    16

    data report help needed

    hi gurus,

    i am working with a VB project. i am using Datareports as reporting tool. can i use "KeepTogether" property for a set of

    sections. that is i have 3 sections(Group header,Details Section and Group footer). can i keep these 3 sections togetether

    without a section being split between 2 pages? These sections keep on repeting for pages. i want to keep 3 sections in a

    single page on every occurance. and can i limit the number of times these 3 sections(Group header,Details Section and Group

    Footer constitute one SET) occur together in a page?

    and i have one more issue relating to data report. can i have 2 or more datasources for a single datareport using

    parametrized queries.how to do this.

    please help.
    thanks in advance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured