×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Sort key not sorting

Sort key not sorting

Sort key not sorting

(OP)
When I try to sort the CompanyName field, it does nothing. All the other fields will sort like it suppose to.

Also, CompanyName field is a subform on the main form.

Any suggestions on how to get this to work?

Below is my table structure:

tblCompanies
   CompanyID   dbLong  PrimaryKey  Indexed
   Industry   dbText
   CompanySize   dbText
   Address   dbText
   City   dbText
   State   dbText
   PostalCode   dbText
   DateEntered   dbDate

tblCompanyNames
   CompanyNameID   dbLong  PrimaryKey  Indexed
   CompanyID   dbLong  ForiegnKey  Indexed
   CompanyName   dbText
   DefaultNameToUse   dbBoolean


Name: tblCompaniestblCompanyNames
  Table: tblCompanies
  Foreign Table: tblCompanyNames
  PK: CompanyID   FK:CompanyID

 

RE: Sort key not sorting

There are multiple ways to sort, a query, code, manual, etc.  Can you describe in more detail how you are trying to sort?

RE: Sort key not sorting

(OP)
First, it was set up like this:

1.  Main form with button to click to sort.
2.  Opens frmSort
3.  frmSort has:  1)  an unbound combo box with Row Source:  CompanyID and CompanyName; 2) Option Group with 2 values:  Ascending Descending.

Below is the code:

On Error GoTo ErrorHandler

    If cboSortBy.ListIndex > -1 And Not IsNull(cboSortBy.Value) Then
        Forms!fmainCompany.OrderBy = Replace(cboSortBy.Value, " ", "") & IIf(optSortOrder.Value = 2, " DESC", " ASC")
        Forms!fmainCompany.OrderByOn = True
    End If
    
    DoCmd.GoToRecord , , acLast
    DoCmd.GoToRecord , , acFirst


ExitErrorHandler:
    Exit Sub

ErrorHandler:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
   Resume ExitErrorHandler

CompanyID sorts correctly, but CompanyName does not sort properly.


After trying various things, we created this dummy database to try to see where the problem is.

With this database, we clicked the Microsoft built-in sort button on the Sort & Filter ribbon.  The CompanyName field will not sort but all the other fields will sort.
 

RE: Sort key not sorting

Does your form actually have [CompanyName] in its record source?

What is the record source of fmainCompany?

Duane
Hook'D on Access
MS Access MVP

RE: Sort key not sorting

(OP)
The record source for fmainCompany is tblCompanies.

 

RE: Sort key not sorting

There is no CompanyName in tblCompanies so there is no way you can sort by it.  

Duane
Hook'D on Access
MS Access MVP

RE: Sort key not sorting

(OP)
CompanyName is a subform on Company form joined by CompanyID.

RE: Sort key not sorting

(OP)
Subform (CompanyName)--CompanyName is a subform on the main form.  CompanyID is on the main form.

RE: Sort key not sorting

(OP)
DELETE/IGNORE THIS THREAD, PLEASE!  I GOT WHAT I WAS TRYING TO DO.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close