Results 1 to 15 of 15

Thread: DataReport using data from MSflexgrid

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2017
    Posts
    7

    DataReport using data from MSflexgrid

    Hi..

    I have a MSHflexgrid which contains some data. now i want to print Searched columns form this Grid as a report. How can i do that. How can I create Data Report which prints the data from MSHflexgrid. Main thing is to preview the searched data in data report. Can anyone help me fast please. Its about my mini project in college now only the data report left but this problem arising.
    Thank You

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: DataReport using data from MSflexgrid

    Do I get your course credit if I provide a solution?

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: DataReport using data from MSflexgrid

    No, there isn't any course credit.

    What type of data report are you using, or do you mean "some means to see and print the data"? That second option, while pretty broad, would be kind of unfortunate. Data reports, and printing, can be entire libraries. At best, they are pretty custom to the task at hand. The only reasonably generic kind of a report would be a CSV file, and that isn't really a report at all.
    My usual boring signature: Nothing

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: DataReport using data from MSflexgrid

    The thread title says DataReport, so I assume he is trying to use a VB6 DataReport.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: DataReport using data from MSflexgrid

    Quote Originally Posted by Shaggy Hiker View Post
    No, there isn't any course credit.
    Fine, I'll settle for the degree.

  6. #6
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: DataReport using data from MSflexgrid

    Quote Originally Posted by dilettante View Post
    Fine, I'll settle for the degree.
    The n-th ?

  7. #7
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: DataReport using data from MSflexgrid

    Sam

    All kidding aside, which one do you mean?
    • using VB6 DataReport?
    • by code you create .. CSV being one (comma separated values)?
    • just an image of your FG?
    • something else?


    And oh yeah, Welcome to the Forums ..

    Spoo

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: DataReport using data from MSflexgrid

    If a monkey asks for a banana you don't ask "What kind of banana? A banana, or an orange, or a hamburger?"

  9. #9
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: DataReport using data from MSflexgrid

    Mmmm .. hamburger .. now you're making me hungry

  10. #10
    Frenzied Member
    Join Date
    Jun 2014
    Posts
    1,084

    Re: DataReport using data from MSflexgrid

    Quote Originally Posted by Sam Samuel View Post
    Hi..

    I have a MSHflexgrid which contains some data. now i want to print Searched columns form this Grid as a report. How can i do that. How can I create Data Report which prints the data from MSHflexgrid. Main thing is to preview the searched data in data report. Can anyone help me fast please. Its about my mini project in college now only the data report left but this problem arising.
    Thank You
    easiest way is to create a recordset of the data in the grid you want to see in the datareport
    and make that recordset the datasource of the datareport
    and of cource place textboxes in the detail section of the datareport and set their datafield property to the fields of the recordset

    does the data in the grid come from a recordset ?,if so just use that recordset as the datasource
    do not put off till tomorrow what you can put off forever

  11. #11

    Thread Starter
    New Member
    Join Date
    Sep 2017
    Posts
    7

    Re: DataReport using data from MSflexgrid

    actually there is an search form where data's are searched and those data's are displayed in MSHFLEXGRID. I want to export the data in mshflexgrid into the data report in VB6. That's what am looking for...

  12. #12
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: DataReport using data from MSflexgrid

    Post #10 is your basic answer.

    Yes, it can be done without any Recordset. The only way I know of requires creating a data source class that also implements MSDAOSP.OLEDBSimpleProvider interface (a combined DSO/OSP class). I could provide an example but it is probably more complicated than you need for the small gain.

    I would rewrite your search to accumulate results into a Recordset. Then you can use that to populate both your FlexGrid and DataReport. The bonus is that you don't have to throw away data types (FlexGrids only hold and display text).

  13. #13
    Frenzied Member
    Join Date
    Jun 2014
    Posts
    1,084

    Re: DataReport using data from MSflexgrid

    ok, an example
    Code:
    Private Sub Command1_Click()
        Dim i As Integer
        Dim Column As Integer
        Dim Row As Integer
        Dim rs As ADODB.Recordset
        Dim fld As ADODB.Field
    
        Set rs = New ADODB.Recordset
        rs.Fields.Append "TheField0", adVarChar, 10
        rs.Fields.Append "TheField1", adVarChar, 10
        rs.Fields.Append "TheField2", adCurrency
        rs.Open
        
        MSHFlexGrid1.Rows = 2
        MSHFlexGrid1.FixedRows = 1
        MSHFlexGrid1.Cols = 3
        MSHFlexGrid1.FixedCols = 0
        
        For i = 0 To 2
            MSHFlexGrid1.TextMatrix(0, i) = "Field" & i
        Next
        
        For i = 100 To 1 Step -1
            MSHFlexGrid1.AddItem "AA " & i & Chr(9) & "BB " & i & Chr(9) & Rnd * 100, 1
        Next
        
        For i = 0 To 2
            MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Rows - 1, i) = "TheEnd " & i
        Next
        
        For Row = 1 To MSHFlexGrid1.Rows - 2
            rs.AddNew Array("TheField0", "TheField1", "TheField2"), Array(MSHFlexGrid1.TextMatrix(Row, 0), MSHFlexGrid1.TextMatrix(Row, 1), CCur(MSHFlexGrid1.TextMatrix(Row, 2)))
        Next
        
        Set DataReport1.DataSource = rs
        DataReport1.Show vbModal
        
        rs.Close
    End Sub
    do not put off till tomorrow what you can put off forever

  14. #14
    Frenzied Member
    Join Date
    Jun 2014
    Posts
    1,084

    Re: DataReport using data from MSflexgrid

    now that you have an example of exactly what you asked for:
    an example of how it should have been done: (as suggested by dilettante)
    Code:
    Private Sub Command2_Click()
        Dim Row As Integer
        Dim rs As ADODB.Recordset
        Dim fld As ADODB.Field
    
        Set rs = New ADODB.Recordset
        rs.Fields.Append "TheField0", adVarChar, 10
        rs.Fields.Append "TheField1", adVarChar, 10
        rs.Fields.Append "TheField2", adCurrency
        rs.Open
    
        For Row = 1 To 1000
            rs.AddNew Array("TheField0", "TheField1", "TheField2"), Array("AA " & CStr(Row), "BB " & CStr(Row + 1), Rnd * 100)
        Next
        
        Set MSHFlexGrid1.Recordset = rs
        Set DataReport1.DataSource = rs
        DataReport1.Show vbModal
        
        rs.Close
    End Sub
    do not put off till tomorrow what you can put off forever

  15. #15

    Thread Starter
    New Member
    Join Date
    Sep 2017
    Posts
    7

    Re: DataReport using data from MSflexgrid

    Thanks for the answers. And help. It helped

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