heatherme
asked on
sort data report?
I have an app that uses a lot of VB's DataReports. The sql statement in the dataenviroment has the records sorted one way, say by author. I would like the user to be able to click the label describing a field and then have the records sorted by that field (say they wanted to print the report sorted by isbn instead of author). I would rather not have to change the sql statement in the dataenvironment. I have found no click event in the datareport (unless i missed something). Can this even be done? I will increase points if someone has a good way to do this. I am using VB6
I think the DataReport doesn`t support any event.
yes, u have a way to do this with that Data Reports thingy. If you create command's sql strings to create your connection just create your SQL string how user need to sort data. Use ORDER BY in sql string. then refresh connection (i hope you know how you can refresh the Data Report, becacuse i wasted my 3 days to find a way to do that. You just need to populate the recordset object by using rcset.movelast:rcset.movef irst) But you also need to close and reopen the datareport.
If you are interested on my solution and also need more info to do it let me know please.
If you are interested on my solution and also need more info to do it let me know please.
Just a thought:
Read the recordset into memory using ADO. Then sort it using the users preference. Then fill a 'dummy' table using that data.
Place an ADODC control ,which connects to that dummy table, on the datareport and let the datareport be populated though that control.
D'Mzzl!
RoverM
Read the recordset into memory using ADO. Then sort it using the users preference. Then fill a 'dummy' table using that data.
Place an ADODC control ,which connects to that dummy table, on the datareport and let the datareport be populated though that control.
D'Mzzl!
RoverM
ASKER
smozqur -
I am interested in your solution.. Could you provide a code example for it?
I am interested in your solution.. Could you provide a code example for it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
smozqur -
Just wanted to let you know that i tried your solution and so far, i have gotten mixed results. it worked initially, but now i am getting an error on the recprdset.open statement. I has created a test application to test the solution. Hopefully, i will be able to test it in my applicaton this weekend. if not, i probably will over the holiday. Just wanted to let you know what was happening.
Just wanted to let you know that i tried your solution and so far, i have gotten mixed results. it worked initially, but now i am getting an error on the recprdset.open statement. I has created a test application to test the solution. Hopefully, i will be able to test it in my applicaton this weekend. if not, i probably will over the holiday. Just wanted to let you know what was happening.
Do you know what you do if you open a recordset and want to learn recordcount in it? Yes you know.. if you dont then please open a recordset and after this code:
Set rcset=blah.openrecordset(b lahdb)
now if you want to learn recordcount you write this:
msgbox rcset.recordcount
then it will appear a message box which tells you 1 (just one: if you have at least one record in database but may be thousand)
It means you have wrong solution because you have to populate the recordset before getting this result just with this code:
rcset.movelast:rcset.movef irst
then if you use
msgbox rcset.recordcount
then you will get the correct solution.
I applied same thing here. ok? It runs for me here and will run for you i am sure.
Good luck again
Set rcset=blah.openrecordset(b
now if you want to learn recordcount you write this:
msgbox rcset.recordcount
then it will appear a message box which tells you 1 (just one: if you have at least one record in database but may be thousand)
It means you have wrong solution because you have to populate the recordset before getting this result just with this code:
rcset.movelast:rcset.movef
then if you use
msgbox rcset.recordcount
then you will get the correct solution.
I applied same thing here. ok? It runs for me here and will run for you i am sure.
Good luck again