Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Nov 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setting record display order (2000)

    I find myself using access, which I have not used before, but I do have other programming background. I have a simple one table database with customer ID, name, addess etc., and have indicated that I want to index on ID, name, city when I set up the table. How on my form do I have controls that when clicked on will change the order that the records are displayed when you scroll through them? ie: in id order or name order. How do you set the index?

    thanks for any help.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Setting record display order (2000)

    You can set the OrderBy property of the form to the name of field you want to sort on, and the OrderByOn property to True to activate the custom sort order.
    You could do the following:
    - Put a combo box cboSort on the form. Leave its Control Source blank.
    - If you want the user to be able to sort only on the fields you name, set the Row Source Type property of the combo box to Value List, and enter the list of fields separated by semi-colons in the Row Source property, for example ID;Name;City.
    - If you want the user to be able to sort on all fields, set the Row Source Type property to Field List, and enter the name of the table in the Row Source property.
    - Create the following After Update event procedure for the combo box:

    Private Sub cboSort_AfterUpdate()
    If IsNull(Me.cboSort) Then
    ' Turn custom sort order off
    Me.OrderBy = ""
    Me.OrderByOn = False
    Else
    ' Turn custom sort order on
    Me.OrderBy = Me.cboSort
    OrderByOn = True
    End If
    End Sub

  3. #3
    New Lounger
    Join Date
    Nov 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting record display order (2000)

    Thanks, that works, it was too simple for me to see the forest for the trees.

    Jim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •