Hye there
I have to create a Report which get Get Data from Forms controls.Please help with any simple example.
thx

Hi there,

I would like to know how to set the caption property of a label on a Data Report form code. In the form I tried

Code:datareport1.labael1.caption ="text here"
datareport1.show (1)

but it doesn't recognise label1.

Any suggestion?

Thanks

I have text box in form and datareport and
my scenario is,
1.I have a textbox in a form and textbox in a datareport
2.I typed some text in the text box
3.When i click a command button the content of the text box moves to datareport textbox
4.In this, I want the particular word in the text should be bold while displaying in the datareport textbox, since the Bold word is the heading in the data report textbox.
5. Changing the datareport textbox font to bold during design time will result all the text in the textbox to bold.But i need only the particular word bold it may done only during runtime i think.

This an example :
Modified as u needed.

Set rsTest = New ADODB.Recordset

With rsTest.Fields
.Append "Field1", adBSTR
.Append "Field2", adBSTR
.Append "Field3", adBSTR
End With

rsTest.Open

With rsTest
.AddNew
.Fields("Field1") = "Test1"
.Fields("Field2") = "Test2"
.Fields("Field3") = "Test3"
.Update
End With
Set DataReport1.DataSource = rsTest
With DataReport1.Sections("Section1")
.Controls("Text1").DataField = "Field1"
.Controls("Text2").DataField = "Field2"
.Controls("Text3").DataField = "Field3"
End With
DataReport1.Refresh
DataReport1.Show 1
End Sub
commented: Great Code +2
commented: I even never think about this way..it's awesome dude. +2

But i dont want to use any database.My problem is to transfer data of Listview and textboxs (list on any form of VB6 Application ) directly to Database.
Please help me as soon as possible.

commented: You even not trying this code. -3

But i dont want to use any database.

Did u read this code correctly?
This code didn't use any database.
Are you trying this code?

My problem is to transfer data of Listview and textboxs (list on any form of VB6 Application ) directly to Database.

I already give you this sample code, now your turn to modified it with listview items data.

Please help me as soon as possible.

Do not expect this. You not pay me to get this code.

commented: He the lazy one..don't get mad for him. +3

please dont mind ..I am in trouble . i am new in this field please dont pay tension on my minute questions.
I read it buti think there is rsTest which related to database. Can u sent me total Button code. Which transfer data of List view to Data report?

yes i read this code.you are right. there is no database involved.Please send me example where can i put data on datareport from ListView.

please dont mind ..I am in trouble . i am new in this field please dont pay tension on my minute questions.
I read it buti think there is rsTest which related to database. Can u sent me total Button code. Which transfer data of List view to Data report?

yes i read this code.you are right. there is no database involved.Please send me example where can i put data on datareport from ListView.

If you already read it then Make some effort.
I was give you a sample code now your turn to modified it as you needed.
Use looping to get data from listview and update recordset for each row.
Recordset will receive all data from listview.
Set datareport source to recordset then show it to data report.
Just it.

yes it works.
But when i modified it I received the following error.
Run time error 8577
Arguments are of the wrong type,are out of acceptable range,or are in conflict with one another
the code is bellow.

Dim RsTest As Recordset
Dim i As Integer
Set RsTest = New ADODB.Recordset
 
With RsTest.Fields
.Append "Field1", adDouble
.Append "Field2", adBSTR
.Append "Field3", adInteger
End With
 
 RsTest.Open
 For i = 1 To MyList.ListItems.Count
 With RsTest
.AddNew
.Fields("Field1") = MyList.ListItems.Item(i).Text
.Fields("Field2") = MyList.ListItems.Item(i).SubItems(1)
.Fields("Field3") = MyList.ListItems.Item(i).SubItems(2)
.Update

End With
Set DataReport1.DataSource = RsTest
With DataReport1.Sections("Section1")
.Controls("Text1").DataField = "Field1"
.Controls("Text2").DataField = "Field2"
.Controls("Text3").DataField = "Field3"
End With
Next i
DataReport1.Refresh
DataReport1.Show 1

1- I changed the type of arguments
With RsTest.Fields
.Append "Field1", adDouble
.Append "Field2", adBSTR
.Append "Field3", adInteger
End With
but i received same error
plz help me.

Good. I Really appreciate when you make some effort.
You made mistake when put "next i". You just need to update the recordset.
You don't have to update data field of datareport. When you assign DataReport source with Recordset it will accommodate all data of listview on recordset.
So, it should be like this :

Dim RsTest As Recordset
Dim i As Integer
Set RsTest = New ADODB.Recordset
 
With RsTest.Fields
.Append "Field1", adDouble
.Append "Field2", adBSTR
.Append "Field3", adInteger
End With
 
RsTest.Open

For i = 1 To MyList.ListItems.Count
    With rsTest
        .AddNew
        .Fields("Field1") = MyList.ListItems(i).Text
        .Fields("Field2") = MyList.ListItems(i).SubItems(1)
        .Fields("Field3") = MyList.ListItems(i).SubItems(2)
        .Update
    End With
Next i ' Put here

Set DataReport1.DataSource = RsTest
With DataReport1.Sections("Section1")
.Controls("Text1").DataField = "Field1"
.Controls("Text2").DataField = "Field2"
.Controls("Text3").DataField = "Field3"
End With

DataReport1.Refresh
DataReport1.Show 1

guys i solved problem to add new datareport.
so thx for help.

guys i solved problem to add new datareport.
so thx for help.

Nice work.

Please help me how I can create a report using code with no data environment connection

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.