Solved

How do I get code to run through recordsets as they are shown?

Posted on 2014-10-06
4
179 Views
Last Modified: 2014-10-22
Firstly, I run an append query to a table.  The data is needing to be in order by Record Locator. The Record Locator Number is a specific column used to to group invoices together.

After the append query is completed and I open the table, the data is shown in the order I want to see it.

I then run the code to loop through all recordsets on that specific table.  However, instead of looping through the recordsets as they are shown the code loops through the recordsets by the order of another column in the table.

I need the loop to recognize the order according to the Record Locator and not the other column.

Help would greatly be appreciated.
0
Comment
Question by:Denise Knell
  • 2
4 Comments
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 40364021
Use the recordset.sort function to sort the recordset on the field and in the order you like.
0
 
LVL 10

Accepted Solution

by:
Anthony Berenguel earned 500 total points
ID: 40364032
for example
rstOriginal.Sort = "id asc" to sort the recordset on the field 'id' in ascending order

Open in new window

0
 
LVL 30

Expert Comment

by:hnasr
ID: 40364054
Try Anthony Berenguel's comment first.

"As they are shown"
Shown where? Displayed in form?

List the code to create the record set. The record set is created using the select statement with Order By phrase.
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 40364954
Tables and queries are unordered sets.  If you want them presented in a particular order, you need to use a query with the Order By clause.  I never used the recordset.sort method but I would guess it to be less efficient than including the Order By clause in the query and letting the server do the sort.  It probably makes no difference if the BE is Jet or ACE but I prefer to use techniques that will work for a server-side database since most of my apps ultimately get "upsized".  If I always use good client/server techniques, I can do the upsizing in a couple of hours at most.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now