How sum a data report column
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: How sum a data report column

  1. #1
    Join Date
    Jul 2011
    Posts
    5

    How sum a data report column

    Dear friends,
    Your valuable advice helps me great. I am totally new in VB6 programming. I create a Data Report without Data Environment. The codes are as follows

    Code:
    private Sub CmdPrint_Click()
    CON.Open ("provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\db1.mdb")
    RS.Open "select * from table1", CON, adOpenDynamic, adLockOptimistic
    Set RPT2.DataSource = RS
        RPT2.Sections("section1").Controls("Text1").DataField = "TYPE"
        RPT2.Sections("section1").Controls("Text2").DataField = "part_no"
        RPT2.Sections("section1").Controls("Text3").DataField = "product_name"
        RPT2.Sections("section1").Controls("Text4").DataField = "mrp"
        RPT2.Sections("section1").Controls("Text5").DataField = "QTY"
        RPT2.Sections("section1").Controls("Text6").DataField = "TOTAL"
        RPT2.WindowState = 2
        RPT2.Show 1
    RS.Close
    CON.Close
    End Sub
    Now I want to print the Total sum of the Total field at the bottom of the report. So, friends what is the code for it?

    Please friends help me in this regard.

  2. #2
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,836

    Re: How sum a data report column

    I do not know about data report as I use Active Reports instead. In Active Reports there is a property that can be set to count or sum rows within a group or wintin a report. I would think that data report has something similar.

    Have you tried a Google search, or your online help?
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jul 2011
    Posts
    5

    Re: How sum a data report column

    Dear Sir, I have zero knowledge about Active reports. Please help me about this regard.

  4. #4
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,836

    Re: How sum a data report column

    As I mentioned I have not used data report but I would expect it has a simple method to do what you seek.

    I'll ask again have you tried a Google search or checked your online help? If not then that should be your first recourse.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: How sum a data report column

    Code:
    RS.Open "select sum(Total) from table1", CON, adOpenDynamic, adLockOptimistic
    bind the result from this query to your total Field...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

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