Consulting

Results 1 to 4 of 4

Thread: Excel VBS SQL Code Problem

  1. #1

    Excel VBS SQL Code Problem

    Hi i am trying to get arecord back from the database specificly the last recort i am using this SQL code.

    [VBA]

    SQL = "Select [amt] from tblrecon]" & _
    "Where [ID]= (Select Max[ID] From [tblrecon]"


    [/VBA]

    But i am getting an automation error

    thank you

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Bit difficult without the whole coide, but you might at least need another space

    [vba]

    SQL = "Select [amt] from tblrecon] " & _
    "Where [ID]= (Select Max[ID] From [tblrecon]"
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location
    I found these brackets issue like opening is there closing is not there & so on

    [VBA] SQL = "Select [amt] from tblrecon] " & _
    "Where [ID]= (Select Max[ID] From [tblrecon]" [/VBA]

    The corrected one as per me is
    [VBA] SQL = "Select [amt] from tblrecon " & _
    "Where [ID]= (Select Max[ID] From [tblrecon])"[/VBA]
    Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
    Practice this & save time of others in thinking for unsolved thread

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    oops missed the bracket
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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