Consulting

Results 1 to 3 of 3

Thread: Solved: VBA SQL statement (xl '97)

  1. #1
    VBAX Tutor phendrena's Avatar
    Joined
    Oct 2008
    Location
    Huddersfield, UK
    Posts
    285
    Location

    Solved: VBA SQL statement (xl '97)

    Hi there,

    I was wondering if someone would be able to point out my error in the following :-
    [vba]
    sSQL = "SELECT * FROM [Dealer List] " & _
    "WHERE [Dealer List].[Scheme] LIKE '" & "Magsys" & "' " & _
    "OR LIKE '" & "Img Systems" & "';"[/vba]
    I get the following error :
    Syntax error (missing operator) in query expression '[Dealer List].[Scheme] LIKE 'Magsys' OR LIKE 'Img Systems''.

    Thanks,
    Somewhere in the dark and nasty regions where nobody goes, stands an ancient castle.
    Deep within this dank and uninviting place lives Berk, overworked servant of The Thing Upstairs.
    But thats nothing compared to the horrors that lurk beneath The Trap Door.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    No expert in SQL, but I guess you need
    SELECT * FROM [Dealer List] WHERE [Dealer List].[Scheme] LIKE 'Magsys' OR [Dealer List].[Scheme] LIKE 'Img Systems';
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Tutor phendrena's Avatar
    Joined
    Oct 2008
    Location
    Huddersfield, UK
    Posts
    285
    Location
    Thank you for the reply and the solution.
    That does indeed work.

    Somewhere in the dark and nasty regions where nobody goes, stands an ancient castle.
    Deep within this dank and uninviting place lives Berk, overworked servant of The Thing Upstairs.
    But thats nothing compared to the horrors that lurk beneath The Trap Door.

Posting Permissions

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