Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Environment/Data Report Designer

Status
Not open for further replies.

Maximus37

Technical User
Dec 7, 2002
21
0
0
US
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.
 
The only thing that I can see in your code that is different than the rest is this in option 4

.DataMember = "rsCommand2"
try removing the rs from "rsCommand2"
 
Hello, thanx for the help.

I've done that but it gives me a different error:
"Data Type Mismatch"

This is what I've tried with the DataReport:

.DataMember=""
.DataMembrer="Command2"

and still the same error, "Data Type Mismatch".
Another thing that I've tried is:

in the DataReport's Properties window, left the .DataSource blank and establish it in code, still the same error.

Hence my approach to .DataMember="rsCommand2", still same error.

It may be something very small we're overlooking becuase when I do a Step by Step Debug (F8), and I get to the Option4 code, even though the DataMember is set to use Command2, the error displays the following:

"DataField 'Command1.RefNo' Not Found"

so, for some reason the code is not setting the DataMember to Command2, but it works just fine in the options using DataMember.Command1.

I hope you can still help me with this, and not bug you so much about it.

I'll await for your expert advice, but will be surfing to find out what is the cause of this, and if I find it, I'll elaborate for you.

It might help us both in for future reference.

Thanx again ZgtrMan.
:)
Max35
 
is your Command2 a child command or a command unto itself of the same table? Also you might want to check you lock status of each command. But this is all speculation without seeing the actual DataEnvironment set up.
 
No, it's not a Child Command, and both of the command's Lock type are set to adLockReadOnly.
It still not working, and I've tried different approaches.

Could it be software installation or the like?

Thanx Zgtrman,

Max35
 
After re reading your original problem, you stated that you were using the same table and the only difference was the the SQL statement. Are all of the fields in the same table? If they are why not just use Command1? Another thing I flashed on was "Data Type Mismatch" This could be due to the field properties in the database itself and not your program. I am wondering if you are have the same problem elsewhere in the program. The reason I am saying this is because according to your code it should work.. the problem is outside the program. You are not bugging me about this because I understand. I too am using the DataEnvironment with DataReports and there isn't a whole lot of help out there concerning this. One more thing...is the field you are trying to retrieve from Command2 have a space on the Report itself? Sorry to keep asking all these types of questions but by not seeing the whole picture this is the only way I have of troubleshooting your dilema.

Let me know...

zgtrman
 
I think you just uncovered my big little mistake :)

in the DataRerport it self, the controls are bound to Command1, so even though I change the DataReport's DataMember to Command2, the controls are still bound to the Command1, but I cannot find a way to bind the Report's contorols in code, is that possible?

Thanx again for your help,
Max35
 
It's a whole lot easier if you just use an ordinary ADO recordset then:
Set dr1.DataSource = rst

If you need to change the datafield in a report programmatically use:

dr1.Sections(3).Controls(59).DataField = "contractid"

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
I am sure that there is because I read about that very thing somewhere on the net but for the life of me I cannot remember where..(I am not at my home computer right now) but it seemed that there was an awful lot of coding involved. Since I do not know the nature of your program I would suggest creating another DataReport for Command2 and just reference that...if I run across that article again I will post the URL here.

zgtrman To effectively improve in the efficiency of your performance, one must be proficient in the implementation of a positive mental attitude.
 
I had thought about that at before running into this dielma, but opted instead of just coding a little more, now I'll do what you suggest.

Thanx for helping and yes, I'd appreciate it to if you send me that article whenever you run into it.

Merry X-mas and a Happy New Year!
 
I did what you suggested JohnWN, but it still gives me an error "Data Type mismatch in criteria expression" but I konw that is not it, I have already checked my database and is defined correctly, I've even redone it.

The strange thing is that when I do a Step-by-Step debug(F8), the report displays with no problem, but not when I run the program.
I'm working now with two separate DataReports each using a separate command, with the command1 there is no problem, but command2 halts and displays the error i mentioned above.
 
Ok.. I found what you are looking for in the form of a program demo that I downloaded from somewhere. However I am unable to upload the file within this forum. This demo creates a datareport without a DataEnvironment, but that is not the point..this demo sheds light on how to approach what you are wanting to do with unbound controls on the report itself. zgtrman@hotmail.com

zgtrman

To effectively improve in the efficiency of your performance, one must be proficient in the implementation of a positive mental attitude.
 
Did this program demo help with what you needed? am having the same problem and its driving me to the point of getting me old speccy out and coding on that!! hehe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top