Results 1 to 4 of 4
  1. #1
    dizy8 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2021
    Posts
    12

    Continuous Form Problem (Ascending Order)

    Hi All,

    I have a continuous form with the code below. After I enter the Recipient, i do get the filtered recipient that I want but all the filtered data are mixed. I want that in my [ID] column to be ascended in order. Please help me for the code. My search button code is below. Thank you so much.

    Private Sub btnSearchOut_Click()
    Dim strSearch As String
    Dim strText As String
    strText = Me.txtKeywordOut.Value
    strSearch = " SELECT * from tbl_Outgoing where ((Recipient like ""*" & strText & "*"")) "
    Me.RecordSource = strSearch
    End Sub

  2. #2
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Add the ORDER BY clause:
    Code:
    Private Sub btnSearchOut_Click()
       Dim strSearch As String
       Dim strText As String
    
       strText = Me.txtKeywordOut
       strSearch = "SELECT *"
       strSearch = strSearch & " FROM tbl_Outgoing"
       strSearch = strSearch & " WHERE ((Recipient like ""*" & strText & "*""))"
       strSearch = strSearch & " ORDER BY tbl_Outgoing.ID ASC"
    
       Me.RecordSource = strSearch
    End Sub

  3. #3
    dizy8 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2021
    Posts
    12
    Hi Steve!!!

    It works perfectly for me!!! Thank you so much for the help!

  4. #4
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Happy to help. Good luck with your project.


    And Welcome to the forum.

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

Similar Threads

  1. Replies: 5
    Last Post: 08-27-2019, 08:41 AM
  2. Problem with continuous form
    By ezybusy in forum Forms
    Replies: 3
    Last Post: 03-30-2019, 04:29 AM
  3. Replies: 2
    Last Post: 12-10-2018, 08:22 PM
  4. sorting table field in ascending order
    By picyx in forum Access
    Replies: 7
    Last Post: 11-18-2014, 02:24 PM
  5. How to order columns in ascending order?
    By darkingthereturn in forum Access
    Replies: 5
    Last Post: 06-18-2012, 05:24 AM

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