473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Sort records in Access

4
I inherited an Access 2003 database and need to change the way a form is sorted. It seems to work like this. There is a table containing work records of work requests. The user fills out a form requesting the work and it is assigned a number using the autonumber feature and the date is also put in automatically, then it is entered in the table. There is another form that other users use to request all records designated as new. The form, via a macro, returns all the records. Somehow it stopped sorting by the autonumber. I tried selecting different fields while the form was in run mode (not design view) but could not select the fields date or autonumber. I can only sort on fields that contain user entered data. Does anyone know how to change this so it always sorts on either autonumber(preferably) or date? When I run a query against the table it sorts by these fields fine, but I don't want to rebuild the whole thing and would rather get the form to work as it used to when called by the macro.

Thanks for your help.
May 31 '07 #1
3 6084
puppydogbuddy
1,923 Expert 1GB
I inherited an Access 2003 database and need to change the way a form is sorted. It seems to work like this. There is a table containing work records of work requests. The user fills out a form requesting the work and it is assigned a number using the autonumber feature and the date is also put in automatically, then it is entered in the table. There is another form that other users use to request all records designated as new. The form, via a macro, returns all the records. Somehow it stopped sorting by the autonumber. I tried selecting different fields while the form was in run mode (not design view) but could not select the fields date or autonumber. I can only sort on fields that contain user entered data. Does anyone know how to change this so it always sorts on either autonumber(preferably) or date? When I run a query against the table it sorts by these fields fine, but I don't want to rebuild the whole thing and would rather get the form to work as it used to when called by the macro.

Thanks for your help.
Try placing this code in the load event of the form: Replace "YourAutoNumberField" with the fields actual Name

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3. On Error GoTo ErrorHandler
  4.  
  5.          Me.OrderBy = "YourAutoNumberField"   
  6.  
  7.          Me.OrderByOn = True                        ' Apply the sort order.
  8.  
  9.    Exit Sub
  10.  
  11. ErrorHandler:
  12.    MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
  13. End Sub
Jun 1 '07 #2
sail87
4
Thanks for your help, that worked!
Jun 1 '07 #3
ebs57
18
I was not able to sort a report by date, either. My SQL was set up to sort a report based on a document name and the date but would only sort by the document name:
Expand|Select|Wrap|Line Numbers
  1. SELECT ID, Name, Date
  2. FROM Documents Doc
  3. WHERE Name <> ""
  4. ORDER BY Doc.Name, Doc.Date;
My report output looked sumtin like dis:

Document 100 5/5/2007
Document 200 6/4/2007
Document 300 5/28/2007

I eliminated the ORDER BY clause from my SQL and played with the report's "Sorting and Grouping" button and that produced the same results. I then swapped the date and name ordering and it worked. For some reason I had to have the date sorted first then the document name. As usual, I don't understand why this worked but in my case whatever combination of keypresses makes database go me happy (or at least ameliorated).
Jun 14 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Nova's Taylor | last post by:
Hi folks, I am a newbie to Python and am hoping that someone can get me started on a log parser that I am trying to write. The log is an ASCII file that contains a process identifier (PID),...
4
by: Matt | last post by:
Hi all, We recently upsized two Microsoft Access Databases to SQL. We're using an ADP (2002) as the front end. All the conversion issues have been resolved, except for one: Whenever we...
40
by: Elijah Bailey | last post by:
I want to sort a set of records using STL's sort() function, but dont see an easy way to do it. I have a char *data; which has size mn bytes where m is size of the record and n is the...
5
by: Bill Reid | last post by:
Hello, I am a just-beyond-beginning user of Access 97 on a Windows 98se machine (a single, non-networked home machine). All of a sudden I am unable to sort any of my tables. I click on any...
4
by: Nhmiller | last post by:
This is directly from Access' Help: "About designing a query When you open a query in Design view, or open a form, report, or datasheet and show the Advanced Filter/Sort window (Advanced...
4
by: Marie | last post by:
My report has a text field named ItemNum. Most records have a value for ItemNum. I set Grouping And Sorting to sort ascending on the ItemNum field. The records where ItemNum is Null appear at the...
6
by: mcollier | last post by:
I have some VB6 code that calls a SELECT query in Microsoft Access. When I run the query from access, the results appear in not particular order. However, when I call the query from VB6, via ADO,...
3
by: brucedodds | last post by:
I have a client who has just migrated from Access 97 to Access XP. He uses make-table queries to sort tables by two fields (text & double) before exporting the records for another application. ...
6
by: Chris Zoper | last post by:
Hello, I have a form that shows a lot of records based on a passthrough query to a SQL Server database. I noticed that the Filter and the Sort property of the form do not properly work, often...
5
by: muskie | last post by:
I've looked through as many posts about this as possible, but all end with no resolution. I simply need records from a table in random order, and I will be calling this recordset in a SQL...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.