PDA

Click to See Complete Forum and Search --> : data report question


binbpk
Sep 7th, 2007, 10:23 PM
hello,
is there a way of adding a data report without requiring a data environment?
i tried doing so but it said invalid data source.
i only want the report to be stimulated from something i've entered on the report instead of from a database as my application wont be having one.

Darkbob
Sep 7th, 2007, 11:17 PM
Short answer: No. Sorry.

yousufkhan
Sep 7th, 2007, 11:26 PM
what exactly you want to do
try passing the values at run time to datareport objects

binbpk
Sep 7th, 2007, 11:33 PM
since i dont have a database, i'll pre-enter data onto the report first.
this is only for testing purposes just to give an idea on what the report would look like.

wes4dbt
Sep 8th, 2007, 12:05 AM
Yes you can use a datareport without a dataenvironment. You just have to set the datasource at runtime.

dim rsRpt As New ADODB.Recordset


With rsRpt
' Create Recordset Fields (Columns) here
.Fields.Append "groupid", adVarChar, 12
.Fields.Append "meter", adVarChar, 12
.Fields.Append "lastread", adDouble
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open
End With

rsRpt.AddNew
rsRpt!Groupid = "abc"
rsRpt!meter = "xyz"
rsRpt!lastread = 123.45
rsRpt.Update
End If

With rptMeterlist
' Bind the Recordset to the Report
Set .DataSource = rsRpt
.DataMember = rsRpt.DataMember
.Show vbModal
End With
set rsrpt=nothing

add the text boxes to your report and set the datafield property to the fields in the recordset and leave the datamember property blank.

binbpk
Sep 8th, 2007, 12:11 AM
this goes in the general declarations?

wes4dbt
Sep 8th, 2007, 12:17 AM
This can go anywhere. I run alot of reports this way, usually from a command button. Just put the code in the click event.

binbpk
Sep 8th, 2007, 12:24 AM
i'm sorry but it says object not found:
Set .DataSource = rsRpt

wes4dbt
Sep 8th, 2007, 12:32 AM
Sounds like it can't find the datareport. Have you created the datarareport? Make sure your using the correct name.

binbpk
Sep 8th, 2007, 12:37 AM
Sounds like it can't find the datareport. Have you created the datarareport? Make sure your using the correct name.
what am i supposed to name it?

wes4dbt
Sep 8th, 2007, 12:42 AM
With rptMeterlist
' Bind the Recordset to the Report
Set .DataSource = rsRpt
.DataMember = rsRpt.DataMember
.Show vbModal
End With

In this example I have a datareport named rptMeterlist. When I used the report designer I left the datasource and datamember properties blank and then I assigned them at runtime, see above.

binbpk
Sep 8th, 2007, 12:48 AM
so if i were to add textboxes, how do i put the values in?

wes4dbt
Sep 8th, 2007, 12:55 AM
What ever you put in the recordset that you assign to the datareport.datasource will show up on the report.

wes4dbt
Sep 8th, 2007, 01:06 AM
I attached a demo program that show how to use a data report without a dataenvironment. I hope this helps

Hack
Sep 8th, 2007, 07:10 AM
Moved to reporting

binbpk
Sep 8th, 2007, 10:03 AM
I attached a demo program that show how to use a data report without a dataenvironment. I hope this helps
thank you very much. i'll have a look at it.