Results 1 to 5 of 5
  1. #1
    mmaule is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    38

    How do I specify a pre-defined index in Order By?

    How do I specify a pre-defined index in Order By?
    When creating a table, I created a multi-field index. Now, in a form using that table, I want to use that index but am having trouble specifing it in the Order By property field.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Sounds like you have a Look Up Field in a table. These are generally frowned upon because of their limitations. One limitation is changing the order of the Value List. The order is determined by the order items are added to the list.

  3. #3
    mmaule is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    38
    When I created the table, I created a foreign Key field (of the parrent table) and a primary key field. I selected Index and created a multi-field index using those fields, with the name SPU_ndx. Now I want to use the index in an associated form.
    I know I can specify [foreign Key field] & [primary key field] in the forms' Order By property, but is there a way to indicate that I want to use the index SPU_ndx, in the forms' Order By property?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    It has been a while since I used it and I am having trouble finding an example. I believe you can do it something like this

    Me.OrderBy "SPU_ndx; [foreign Key field]; [primary key field]"
    or maybe
    Me.OrderBy "SPU_ndx, [foreign Key field], [primary key field]"

    also, you should be able to use the Desc keyword if you do not wish to sort Asc
    Me.OrderBy "SPU_ndx, [foreign Key field], [primary key field] DESC"


    Add the fields to your statement in the order of sort priority.

    I usually avoid properties that are available to the user via intrinsic tools, eg Filter, Order By, etc.
    I would not want a user to override my code by clicking the toolbar somewhere.

    I would try to find a solution by sorting via the Form's RecordSource. Maybe add some SQL to a query object and use that SQL string as the Form's RecordSource.

  5. #5
    mmaule is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    38
    Thanks. I guess I'll just have to specify the fields to order by, given my lack of experience and time limitation.
    Thanks again.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Application-defined or object-defined error
    By SYFYLADY in forum Access
    Replies: 4
    Last Post: 03-05-2014, 05:25 PM
  2. Replies: 3
    Last Post: 11-12-2013, 04:13 PM
  3. user-defined type not defined
    By markjkubicki in forum Programming
    Replies: 3
    Last Post: 05-09-2013, 05:15 PM
  4. Replies: 1
    Last Post: 12-14-2012, 12:32 AM
  5. Application-defined or object-defined error
    By hawkins in forum Access
    Replies: 6
    Last Post: 07-01-2011, 01:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums