TJ_01 Level: VB Lord

 Registered: 24-08-2005 Posts: 320
|
Using DataReport With DataEnvironment
I am not a GURU nor Moderator but i want to share my idea to those who wants to learn basic in using DataReport.
DataReport is much easy to use than Crystal Report. If your using DataEnvironment, you can write your queries at the sql statement. Assuming you want to generate report that the user can input the start date and end date. You code must be something like this:
In your DataEnvironment, Sql Statement:
Select TblName. * from TblName where DateField Between ? and ? |
In your form
Private Sub Command1_Click()
With DataEnvironment1
If .rsCommand1.State = adStateOpen Then .rsCommand1.Close
.Command1 frmName.DTPickerStart.Value, frmName.DTPickerEnd.Value
End With
DataReport.Show
End Sub
|
I used DTPicker control instead of Textbox. You can change the code from
| .Command1 frmName.DTPickerStart.Value, frmName.DTPickerEnd.Value |
To this (if your using Textbox)
| .Command1 frmName.txt1.Text, frmName.txt2.Text |
If you want to assign a textbox value or label caption to your dataReport then:
With DataReportApp
.Sections("section4").Controls.Item("label8").Caption = Text1.Text
.Sections("section4").Controls.Item("label9").Caption = Text2.Text
End With |
If you want to refresh the data in the DataReport instead of closing the whole application then:
if DataEnvironment1.rsNameofDataReport.State <> 0 then
DataEnvironment1.rsNameofDataReport.Close
rptNameofDataReport.Show |
If you want to setup the dataReport properties:
With DataReport1
.Height = 1100
.Width = 1100
.Orientation = rptOrientLandscape
.TopMargin = 200
.BottomMargin = 200
.LeftMargin = 200
.RightMargin = 300
Title of the reports
.caption = "My First DataReport"
.Show 1
End With
|
HTH..
[Edited by TJ_01 on 27-10-2005 at 03:17 AM GMT]
____________________________
Im JAMES
____________________________ Attached:
|