Problem when open data report by selecting date and project code

awiezzz
10-25-2004, 07:07 PM
Hi,
I want to display report by date and projectcode. I have dcProject, dtPicker1, dtPicker2 and cmdOpen in frmReport. This is the code,

Private Sub cmdOk_Click()
Dim pro As String
pro = dcProject.BoundText
DataReport1.Sections("section4").Controls("label16").Caption = "" & pro
DataReport1.Show
End Sub

Private Sub dcProject_Change()
If DataEnvironment1.rsCommand1.State Then _
DataEnvironment1.rsCommand1.Close
DataEnvironment1.Command1 dcProject.BoundText
End Sub


I also create DataReport1 and set DataSource=DataEnvironment1 and DataMember=Command1.
This is the code for Command1,

SELECT ModelCode, VehicleNo FROM tblVehicle


Command1 has child command, Command1child (linked by VehicleNo) and this is the code,

SELECT SumNo, DateOffence, Amount, VehicleNo, Project FROM tblSummon WHERE (Project = ?)


And this is the code for DataReport1,

Private Sub DataReport_Initialize()
Dim strSQL As String
Dim strTo As String
Dim strFrom As String
Dim oConn As New ADODB.Connection
Dim oRS As New ADODB.Recordset

oConn.CursorLocation = adUseClient
oConn.ConnectionString = DataEnvironment1.Connection1
oConn.Open

With frmReport
strTo = .DTPicker1.Value
strFrom = .DTPicker2.Value
End With

DataReport1.Title = "" & strTo & " TO " & strFrom

strSQL = "SHAPE { "
strSQL = strSQL & "SELECT tblVehicle.* "
strSQL = strSQL & "From tblVehicle "
strSQL = strSQL & "} AS Command1 "
strSQL = strSQL & "APPEND ({ "
strSQL = strSQL & "SELECT tblSummon.* "
strSQL = strSQL & "From tblSummon "
strSQL = strSQL & "WHERE DateOffence "
strSQL = strSQL & "BETWEEN #" & strFrom & "# "
strSQL = strSQL & "AND #" & strTo & "# "
strSQL = strSQL & "} AS Command1child "
strSQL = strSQL & "RELATE 'VehicleNo' TO 'VehicleNo') "
strSQL = strSQL & "AS Command1child "

oRS.Open strSQL, oConn, adOpenForwardOnly
Set DataReport1.DataSource = oRS
End Sub


When i open frmReport and select project code and date, this error comes out,
Compile error:
Wrong number of arguments or invalid property assignment.

when i click ok, it goes to this line (dcProject_Change() event)

DataEnvironment1.Command1 dcProject.BoundText


any idea? thanx in advance..;)

Dennis DVR
10-27-2004, 11:16 PM
I don't quite understand what you are doing, you've altered the datasource of you datareport in the Initialize event of the report desginer using the recordset and not the dataenvironment, and you're not even calling the report in the change event of the combo. Are you sure that the dataenvironment didn't complain when you add a parameter in your child command? because i don't see any field in your parent command that would relate the parameter field in your child command.

I think your code needs a major modification.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum