Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2003
    Posts
    10

    Unanswered: "Order By" problem on a SubForm

    I have a customer form that uses a subform called "notes" that lists all relavent notes and is ordered by the date they are created. So on the Form I have in properties under ORDER BY "Notes.Date.DESC" This works and lists the notes in the correct order.

    Now I also have a button to add notes which opens a form called "new notes" and when you type in the notes and click the close botton I have a command line that refreshes the orginal page to update and include the new notes then close the screen the notes were added in. But when the customer form refreshes all the notes in the subform go out of order and are no longer in DESC order.

    Now if I close the customer form and then reopen it, the notes are back in the correct order again. Why isn't the refresh command giving me this effect? Any recomendations?
    Last edited by Cruising270; 09-09-03 at 13:53.

  2. #2
    Join Date
    Feb 2003
    Location
    Auckland, NZ
    Posts
    150
    Have you tried the Requery command?
    JJ Kennedy
    Double J IT Solutions
    www.doublejit.co.nz

    VB 6, VB.NET, ASP.NET, MS SQL Server, MySQL, MS Access

  3. #3
    Join Date
    Sep 2003
    Posts
    10
    Yeah I did the line

    Form_CreditorInfo.Child30.Requery

    but no luck. I just don't get it, because the subform refreshes and shows the new notes. I just dont understand why its not ordering the notes in dec order like it does when the page originally loads. I've been tooling with this all day and no luck. Thanks for the idea though.

  4. #4
    Join Date
    Sep 2003
    Posts
    10
    OK I guess this is what I need if anyone knows it.

    I need the VB command line to order the the Subform "Notes" on the form "CreditorInfo" by the field "date" in decending order. Anyone follow all that?

  5. #5
    Join Date
    Feb 2003
    Location
    Auckland, NZ
    Posts
    150
    You propably have to set the RecordSource of the Subform and then requery it.

    therefore the "new notes" Close event do the following

    Code:
    Forms("CreditorInfo")("Notes").Recordsource = "SELECT * FROM YourTable ORDER BY date DESC"
    
    Forms("CreditorInfo")("Notes").Requery
    Just change YourTable to the table the recordset is based on
    JJ Kennedy
    Double J IT Solutions
    www.doublejit.co.nz

    VB 6, VB.NET, ASP.NET, MS SQL Server, MySQL, MS Access

  6. #6
    Join Date
    Sep 2003
    Posts
    10
    I tried the code but couldn't get the command to work. I must be typing something wrong, I tried pretty much word for word what you wrote above. Here is the info of all the names of the forms and objects. Could you please write the code again word for word what I have to type.

    Form - CreditorInfo
    Subform (object name) - Child30
    Form that subform gets info from - Notes
    Text box to order info by in subform - Date

    Thanks for all the help

  7. #7
    Join Date
    Feb 2003
    Location
    Auckland, NZ
    Posts
    150
    You need to use the subform's actual name not the object name.
    JJ Kennedy
    Double J IT Solutions
    www.doublejit.co.nz

    VB 6, VB.NET, ASP.NET, MS SQL Server, MySQL, MS Access

Posting Permissions

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