"Order By" fails in form for linked table.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ptbrady

    "Order By" fails in form for linked table.

    "Order By" fails in form for linked table.
    --------------
    My A2K database has worked well for several years, but now has been split
    into front-end/back-end and has the following problem. I have a form to access
    a table which I'll call "NameTable" . It has a simple structure:
    ------------
    EmployeeID FirstName (Other fields)
    (autonumber,
    primary key)
    ---------------
    1 Baker
    2 Dog
    3 Charlie
    4 Edward
    5 Able

    ---------------
    In the form, the "Record Source" is "NameTable" , and the "Order By" is
    "NameTable.Firs tName"
    ---------------
    When the NameTable was in the same module as the main program, this worked
    fine. When the form came up, the first record displayed had the name "Able,"
    and if you went to the Next Record (click on the arrow at the base of the
    screen) you then went to Baker, Charlie, etc.
    But now, the NameTable is in another Access module, and is accessed via a link.
    When the form comes up, the first record shown is Baker, then Dog, etc, that
    is, in the order of the EmployeeID, the primary key. It doesn't matter what
    field I put in the "Order By" variable; the order always is the primary key.
    All the rest of the controls work OK, and I can enter and/or change any field I
    want.
    Am I missing something? Thanks. Pete Brady
  • Allen Browne

    #2
    Re: "Order By" fails in form for linked table.

    Did you remember to set the OrderByOn property as well?

    A better solution might be to change the RecordSource property of the form
    to a query statement that specifies how you want it sorted:
    SELECT TableName.* FROM TableName ORDER BY FirstName;

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Ptbrady" <ptbrady@aol.co m> wrote in message
    news:2004030321 3230.09401.0000 0733@mb-m12.aol.com...[color=blue]
    > "Order By" fails in form for linked table.
    > --------------
    > My A2K database has worked well for several years, but now has been[/color]
    split[color=blue]
    > into front-end/back-end and has the following problem. I have a form to[/color]
    access[color=blue]
    > a table which I'll call "NameTable" . It has a simple structure:
    > ------------
    > EmployeeID FirstName (Other fields)
    > (autonumber,
    > primary key)
    > ---------------
    > 1 Baker
    > 2 Dog
    > 3 Charlie
    > 4 Edward
    > 5 Able
    >
    > ---------------
    > In the form, the "Record Source" is "NameTable" , and the "Order By" is
    > "NameTable.Firs tName"
    > ---------------
    > When the NameTable was in the same module as the main program, this worked
    > fine. When the form came up, the first record displayed had the name[/color]
    "Able,"[color=blue]
    > and if you went to the Next Record (click on the arrow at the base of the
    > screen) you then went to Baker, Charlie, etc.
    > But now, the NameTable is in another Access module, and is accessed via a[/color]
    link.[color=blue]
    > When the form comes up, the first record shown is Baker, then Dog, etc,[/color]
    that[color=blue]
    > is, in the order of the EmployeeID, the primary key. It doesn't matter[/color]
    what[color=blue]
    > field I put in the "Order By" variable; the order always is the primary[/color]
    key.[color=blue]
    > All the rest of the controls work OK, and I can enter and/or change any[/color]
    field I[color=blue]
    > want.
    > Am I missing something? Thanks. Pete Brady[/color]


    Comment

    • Ptbrady

      #3
      Re: &quot;Order By&quot; fails in form for linked table.

      Allenb, Thanks for your reply. I put this command in the "On Current" event
      for the table:
      OrderByOn = True
      This fixes the problem. However, I still cannot understand why this would not
      be automatic when I have an "Order by" specified, and why it works in a table
      within this mdb module and but not when it is linked.
      Anyway, thank you for getting me out of this bind! Pete Brady

      Comment

      • Allen Browne

        #4
        Re: &quot;Order By&quot; fails in form for linked table.

        (Putting it in the Open event may be more efficient.)

        --
        Allen Browne - Microsoft MVP. Perth, Western Australia.
        Tips for Access users - http://allenbrowne.com/tips.html
        Reply to group, rather than allenbrowne at mvps dot org.

        "Ptbrady" <ptbrady@aol.co m> wrote in message
        news:2004030409 2416.20639.0000 0877@mb-m24.aol.com...[color=blue]
        > Allenb, Thanks for your reply. I put this command in the "On Current"[/color]
        event[color=blue]
        > for the table:
        > OrderByOn = True
        > This fixes the problem. However, I still cannot understand why this would[/color]
        not[color=blue]
        > be automatic when I have an "Order by" specified, and why it works in a[/color]
        table[color=blue]
        > within this mdb module and but not when it is linked.
        > Anyway, thank you for getting me out of this bind! Pete Brady[/color]


        Comment

        Working...