Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ADO Recordset

Posted on 2002-07-24
6
Medium Priority
?
221 Views
Last Modified: 2013-11-26
OK I have a component which has a method which returns an

id
Staffid,
Roleid,

From this i can call another method to return the staff name using the staff id.

I would like to order the recordset by the staff name. Is there anyway this can be done?
0
Comment
Question by:mm_glebe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Expert Comment

by:wensinkg
ID: 7174034
You could structure the SQL statement to take that into account or you could use the Sort function of ADO.  Your statement would look like this:

SELECT ID, StaffID, RoleID from <TableNameHere> Order By StaffID

Or if you cannot do this for whatever reason use:

rs.Sort "StaffID ASC<Or DESC>"

Be aware that if you use the latter you must use a static, Client Side Cursor on your recordset.  I use this all of the time with disconnected recordsets so that I can change the order that information that appears in lists and combo boxes.  A disconnected recordset also conserves network resources.
0
 

Author Comment

by:mm_glebe
ID: 7174064
I can't amend the SQL statement (stored procedure) at this time.

I'm also aware of the sort method but this will only help for the id. I want ot sort on staffname, which is not in the original recordset.
0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7174261


>>rs.Sort "StaffID ASC<Or DESC>"

that should be:
rs.Sort="StaffID ASC<Or DESC>"

'you missed the equal to..

-priya
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Expert Comment

by:wensinkg
ID: 7174539
Absolutely correct.  Sorry.
0
 
LVL 5

Accepted Solution

by:
bob_online earned 300 total points
ID: 7175132
If this is a read only recordset, you can

Disconnect the recordset (Set ActiveConnection = nothing)
Add a field to the fields collection or the recordset.

Loop through the recordset and for each record
  Run your process to get the staff name for each id
  set the value of your new field to the staff name

Sort on the new field.

The simple approach is, of course, to modify the original sql to return that value, but if that is not an option...
0
 
LVL 2

Expert Comment

by:mmcmillen
ID: 7176222
strsql = "select d,staffid, rollid, staffname from [tablea]

inner join [tableb] on [tablea].staffid = [tableb].staffid


order by staffname
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question