Results 1 to 7 of 7

Thread: [RESOLVED] syntax error "select max(fields) from table"

Threaded View

  1. #1

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Resolved [RESOLVED] syntax error "select max(fields) from table"

    I have a table "ORDER" database access 2k its structure is:

    orderid = autonumber
    orderdate= date
    supplierid=text
    suppliername=text

    in my form have a textbox name "txtnota" and a command button click event code:
    VB Code:
    1. Private Sub command1_Click()
    2.     call RsTmp
    3. end sub
    4.  
    5.  
    6. Sub RsTmp()
    7. Dim RsTmp As ADODB.Recordset
    8.  
    9. msql = "select * from order " & _
    10.        "where orderid in (select max(orderid) from order)"
    11. [b]Set RsTmp = con_cashReg.Execute(msql) 'error here[/b]
    12. If Not (RsTmp Is Nothing) Then
    13.    If (Not RsTmp.BOF) And (Not RsTmp.EOF) Then
    14.       txtnota.Text = RsTmp.Fields("orderid").Value + 1
    15.    Else
    16.    txtnota.Text = 1
    17.    End If
    18.    RsTmp.Close
    19. End If
    20. End Sub

    the run time error is:
    "syntax error in FROM clause"
    Im regard it can get max number from "OrderId" field and add 1 to it
    i dont know what wrong with this, If any one can help me is very much appreciated. thanks in advance

    best regard

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