Datareport Without Using DataEnvirontment
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Datareport Without Using DataEnvirontment

  1. #1
    Join Date
    Feb 2013
    Posts
    34

    Datareport Without Using DataEnvirontment

    Hello Guys.. I am Using Data Report an not using Data Environtment
    This is My Code
    Code:
    Sub receipt()
    Dim rsReport As New ADODB.Recordset
    
    rsReport.Open "Select Receipt, ProductName, Quantity, TotalPrice From Dailyrecord", acd, adOpenForwardOnly
    
    If rsReport.RecordCount > 0 Then
    
        Set DataReport1.DataSource = rsReport
            With DataReport1
                .Sections("Section2").Controls.Item("receipt").Caption = "Receipt"
                .Sections("Section1").Controls("txtproduct").DataField = "ProductName"
                .Sections("Section1").Controls("txtqty").DataField = "Quantity"
                .Sections("Section1").Controls("txttotal").DataField = "TotalPrice"
                .Show
            End With
    
                End If
    End Sub
    What is the problem in my code? Because when i run it,, Run Successful but in my receipt The Receipt number Show the Receipt name instead of the number in my database like 2013-0001 iam using MSACCESS database 2003 Help me guys.. The rest of my code is perfectly run.. Except in the section 2..

    help me guys... hope you understand thanks in Adavance ^_^

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,833

    Re: Datareport Without Using DataEnvirontment

    Well I do not use the data report tool that comes with VB so I know very little about it but it looks like you are setting the caption to "Receipt" so I would expect the word Receipt to appear there on your report. If your intent was to use the data field receipt then one would think you need to assign the data field rather than the caption property.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Feb 2013
    Posts
    34

    Re: Datareport Without Using DataEnvirontment

    Hello Sir But DataField not Allowed in Section 2.. What Should I Do? HElp me Sir

  4. #4
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,833

    Re: Datareport Without Using DataEnvirontment

    Like I said I do not use that tool so I know very little about it. Looks like you would have to set that value through code or change the report a bit, can't say for sure.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Feb 2013
    Posts
    34

    Re: Datareport Without Using DataEnvirontment

    Sir thanks.. This is my code..

    Run Perfectly
    Code:
    Sub receipt()
    Dim rsReport As New ADODB.Recordset
    Dim reciept1 As String
    Dim Purchase1 As String
    Dim name1 As String
    
    rsReport.Open "Select purchase_date, Receipt, ProductName, Quantity, TotalPrice From Dailyrecord where Receipt ='" & lblrp.Caption & "' ", acd, adOpenForwardOnly
    reciept1 = rsReport!receipt
    Purchase1 = rsReport!purchase_date
    name1 = MDIForm1.Label1.Caption
    
    DataReport1.PrintReport True
    If rsReport.RecordCount > 0 Then
    
        Set DataReport1.DataSource = rsReport
            With DataReport1
                .Sections("Section2").Controls.Item("receipt").Caption = reciept1
                .Sections("Section2").Controls.Item("lbldate").Caption = Purchase1
                .Sections("Section5").Controls.Item("lblname").Caption = name1
                .Sections("Section1").Controls("txtproduct").DataField = "ProductName"
                .Sections("Section1").Controls("txtqty").DataField = "Quantity"
                .Sections("Section1").Controls("txttotal").DataField = "TotalPrice"
                .Show
            End With
    
                End If
    SalesNew.Hide
    End Sub

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center