Select Statement with Order By

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • susand1
    New Member
    • Feb 2007
    • 4

    Select Statement with Order By

    Hi, I am very new with VB and had a nice select statement working, then realised I had to do an Order By and now it will not work.

    I need to return a result set that is ordered by a id number.

    Here is the statement that I have

    AddTranRecords "SELECT tblTransactions .PDAID,tblTrans actions.Transac tionID, tblTransactions .TransDate, tblTransactions .Branch, tblTransactions .Description, tblTransactions .Debit, tblTransactions .Credit, tblTransactions .Paid FROM tblLoan INNER JOIN tblTransactions ON tblLoan.PDAID = tblTransactions .PDAID WHERE tblLoan.CustID =" & Me.CustID & "ORDER BY tblTransactions .PDAID ASC"

    It works fine without the order by, I am struggling to get my head around how the string is laid out.

    Thanks
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    Change

    [PHP]Me.CustID & "ORDER BY tblTransactions .PDAID ASC"[/PHP]

    to

    [PHP]Me.CustID & " ORDER BY tblTransactions .PDAID ASC"[/PHP]

    You need a space betwee CstID and ORDER BY.... :)

    Comment

    • susand1
      New Member
      • Feb 2007
      • 4

      #3
      thank you - so simple I will watch that from now on.

      Comment

      Working...