Results 1 to 6 of 6

Thread: Sorting Access table

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Location
    Or
    Posts
    316

    Unhappy

    I am STUMPED. Can someone please tell me how you would sort an access table through code. I have tried using the ORDER BY, but either I am not using it correctly, or it only works with queries, because it is not doing the job.

    Thanks,

  2. #2
    Lively Member
    Join Date
    Dec 1999
    Location
    Karlsruhe, Germany
    Posts
    122

    Question

    ORDER BY should work, can you give me the SQL statement?

    Roger

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Location
    Or
    Posts
    316
    I tried using:

    Code:
    cmdtext = "SELECT surl,ptitle,stitle,sbib,serror,sid FROM temptable ORDER BY serror DESC;"
    
    
        'connect to the database and retrieve the code
        Set adoCon = CreateObject("ADODB.Connection")
        adoCon.Open gblConnectString
        Set adoCmd = CreateObject("ADODB.Command")
        adoCmd.ActiveConnection = adoCon
        adoCmd.CommandText = cmdtext
        adoCmd.Execute

  4. #4
    Addicted Member JasonGS's Avatar
    Join Date
    May 2000
    Location
    California
    Posts
    155
    That would sort your "recordset", that would not sort the Access table.

  5. #5
    Lively Member
    Join Date
    Dec 1999
    Location
    Karlsruhe, Germany
    Posts
    122
    exactly, try:

    Code:
    cmdtext = "SELECT surl,ptitle,stitle,sbib,serror,sid FROM temptable ORDER BY serror DESC;"
    
    dim adoRec as ADODB.Recordset
    
        'connect to the database and retrieve the code
        Set adoCon = CreateObject("ADODB.Connection")
        adoCon.Open gblConnectString
        Set adoCmd = CreateObject("ADODB.Command")
        adoCmd.ActiveConnection = adoCon
        adoCmd.CommandText = cmdtext
        set adoRec = adoCmd.Execute
    
        do while not adoRec.eof
            debug.print adoRec.Fields("serror").value
            adoRec.MoveNext
        loop
    serror is printed sorted in descending order

    Roger




  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Location
    Or
    Posts
    316

    Talking

    Thanks,

    Works exactly like you said.


Posting Permissions

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



Click Here to Expand Forum to Full Width