Solved

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

Posted on 2014-10-06
4
187 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 35

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

822 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