-
Sep 25th, 2017, 10:50 AM
#1
Thread Starter
New Member
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
-
Sep 25th, 2017, 12:42 PM
#2
Re: DataReport using data from MSflexgrid
Do I get your course credit if I provide a solution?
-
Sep 25th, 2017, 01:28 PM
#3
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
-
Sep 25th, 2017, 01:57 PM
#4
Re: DataReport using data from MSflexgrid
The thread title says DataReport, so I assume he is trying to use a VB6 DataReport.
-
Sep 25th, 2017, 01:58 PM
#5
Re: DataReport using data from MSflexgrid
Originally Posted by Shaggy Hiker
No, there isn't any course credit.
Fine, I'll settle for the degree.
-
Sep 25th, 2017, 03:42 PM
#6
Re: DataReport using data from MSflexgrid
Originally Posted by dilettante
Fine, I'll settle for the degree.
The n-th ?
-
Sep 25th, 2017, 03:50 PM
#7
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
-
Sep 25th, 2017, 03:54 PM
#8
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?"
-
Sep 25th, 2017, 04:06 PM
#9
Re: DataReport using data from MSflexgrid
Mmmm .. hamburger .. now you're making me hungry
-
Sep 25th, 2017, 04:07 PM
#10
Re: DataReport using data from MSflexgrid
Originally Posted by Sam Samuel
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
-
Sep 26th, 2017, 07:45 AM
#11
Thread Starter
New Member
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...
-
Sep 26th, 2017, 10:01 AM
#12
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).
-
Sep 26th, 2017, 05:59 PM
#13
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
-
Sep 28th, 2017, 12:41 AM
#14
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
-
Oct 25th, 2017, 08:20 AM
#15
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|