Hello guys, I have the following code in VB6sp5, using Access97 db:
If Option2.Value = True Then
With DataEnvironment1
If .rsCommand1.State = adStateOpen Then
.rsCommand1.Close
End If
.Command1 dbcMedium, "01/01/1990", Date
With DataReport3
.DataMember = "Command1"
.Orientation = rptOrientLandscape
.Title = "Referencias Registradas para " & dbcMedium.Text
.Caption = "Reporte General para " & dbcMedium.Text
.Show
End With
End With
End If
If Option3.Value = True Then
With DataEnvironment1
If .rsCommand1.State = adStateOpen Then
.rsCommand1.Close
End If
.Command1 dbcMedium.Text, DTPicker1.Value, DTPicker2.Value
With DataReport3
.DataMember = "Command1"
.Orientation = rptOrientLandscape
.Caption = "Reporte de Referencias"
.Title = "Referencias Registradas para " & dbcMedium.Text & " del " & DTPicker1.Value & " al " & DTPicker2.Value
.Show
End With
End With
End If
If Option4.Value = True Then
DTPicker1.Value = "01/01/1990"
DTPicker2.Value = Date
With DataEnvironment1
If .rsCommand2.State = adStateOpen Then
.rsCommand2.Close
End If
.Command2 dbcMedium, DTPicker1, DTPicker2
With DataReport3
'Set .DataSource = DataEnvironment1
.DataMember = "rsCommand2"
.Orientation = rptOrientLandscape
.Caption = "Reporte de Referencias"
.Title = "Referencias Registradas para " & dbcMedium
.Show
End With
.rsCommand2.Close
End With
End If
If Option5.Value = True Then
With DataEnvironment1
If .rsCommand2.State = adStateOpen Then
.rsCommand2.Close
End If
.Command2 dbcMedium.Text, DTPicker1.Value, DTPicker2.Value
With DataReport3
Set .DataSource = DataEnvironment1
.DataMember = "Command2"
.Orientation = rptOrientLandscape
.Caption = "Reporte de Referencias"
.Title = "Referencias Regeistradas para " & dbcMedium.Text & " del " & DTPicker1.Value & " al " & DTPicker2.Value
.Show
End With
.rsCommand2.Close
End With
End If
This a command button that should display a datareport.
The first two options work just fine, but as soon as I try to display the datareport of option4, this error displays
"Failed getting Rowset(s) from the current data source"
I'm using the same database and table; the same SQL for both DataEnvironment1.Command# (Command1, Command2) except that in Command2, the SQL just changes a field, for instance, instead of Consignee it tries to retrieve Shipper, but the rest is set the same as Command1 and its properties for the parameters and data, etc. yet Command1 works but not Command2.
If debug step by step, it shows that when it is supposed to execute Command2, it does Command1.
What am I doing wrong ?
Thank you a lot for your expert and valuable advice.
Max35.
If Option2.Value = True Then
With DataEnvironment1
If .rsCommand1.State = adStateOpen Then
.rsCommand1.Close
End If
.Command1 dbcMedium, "01/01/1990", Date
With DataReport3
.DataMember = "Command1"
.Orientation = rptOrientLandscape
.Title = "Referencias Registradas para " & dbcMedium.Text
.Caption = "Reporte General para " & dbcMedium.Text
.Show
End With
End With
End If
If Option3.Value = True Then
With DataEnvironment1
If .rsCommand1.State = adStateOpen Then
.rsCommand1.Close
End If
.Command1 dbcMedium.Text, DTPicker1.Value, DTPicker2.Value
With DataReport3
.DataMember = "Command1"
.Orientation = rptOrientLandscape
.Caption = "Reporte de Referencias"
.Title = "Referencias Registradas para " & dbcMedium.Text & " del " & DTPicker1.Value & " al " & DTPicker2.Value
.Show
End With
End With
End If
If Option4.Value = True Then
DTPicker1.Value = "01/01/1990"
DTPicker2.Value = Date
With DataEnvironment1
If .rsCommand2.State = adStateOpen Then
.rsCommand2.Close
End If
.Command2 dbcMedium, DTPicker1, DTPicker2
With DataReport3
'Set .DataSource = DataEnvironment1
.DataMember = "rsCommand2"
.Orientation = rptOrientLandscape
.Caption = "Reporte de Referencias"
.Title = "Referencias Registradas para " & dbcMedium
.Show
End With
.rsCommand2.Close
End With
End If
If Option5.Value = True Then
With DataEnvironment1
If .rsCommand2.State = adStateOpen Then
.rsCommand2.Close
End If
.Command2 dbcMedium.Text, DTPicker1.Value, DTPicker2.Value
With DataReport3
Set .DataSource = DataEnvironment1
.DataMember = "Command2"
.Orientation = rptOrientLandscape
.Caption = "Reporte de Referencias"
.Title = "Referencias Regeistradas para " & dbcMedium.Text & " del " & DTPicker1.Value & " al " & DTPicker2.Value
.Show
End With
.rsCommand2.Close
End With
End If
This a command button that should display a datareport.
The first two options work just fine, but as soon as I try to display the datareport of option4, this error displays
"Failed getting Rowset(s) from the current data source"
I'm using the same database and table; the same SQL for both DataEnvironment1.Command# (Command1, Command2) except that in Command2, the SQL just changes a field, for instance, instead of Consignee it tries to retrieve Shipper, but the rest is set the same as Command1 and its properties for the parameters and data, etc. yet Command1 works but not Command2.
If debug step by step, it shows that when it is supposed to execute Command2, it does Command1.
What am I doing wrong ?
Thank you a lot for your expert and valuable advice.
Max35.