+ Reply to Thread
Results 1 to 8 of 8

Thread: missing operator error

  1. #1
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    missing operator error

    Hi i have some code

    rst.Open "Select HD as type From ChannelBrand where [Channel Brand] = '" & Cells(r, 1) & "'", conn
    If rst.EOF = False Then state = rst!Type
    rst.Close
    If state = True Then
    tag = 1
    GoTo continue
    End If
    
    
    rst.Open "Select 3D as type From ChannelBrand where [Channel Brand] = '" & Cells(r, 1) & "'", conn
    If rst.EOF = False Then state = rst!Type
    rst.Close
    If state = True Then
    tag = 2
    GoTo continue
    End If

    the idea being that if hd = false then it runs the 3d code and if the 3d = false it runs some other code...

    i get an error when 3d = false, but not when hd = false
    i assumed it was an issue with channel brand being incorrect, but this doesn't appear to be the case

    whats wrong?

    thanks

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: missing operator error

    What error and on which line?

  3. #3
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Re: missing operator error

    the error is:

    Syntax error (missing operator) in query expression '3D'.

    on the line

    rst.Open "Select 3D as type From ChannelBrand where [Channel Brand] = '" & Cells(r, 1) & "'", conn

    which is odd as the HD query performs fine
    Last edited by romperstomper; 10-28-2010 at 07:18 AM. Reason: correct tag

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: missing operator error

    Enclose the 3D in square brackets.

  5. #5
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Re: missing operator error

    ah i see! this works now! thankyou!

    is this because of the use of a number?


    thanks


    Jonathan

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: missing operator error

    Yes. In strict SQL, database object names should begin with a letter and only include letters, numbers or underscoress, but many db systems allow you to violate that. If you do, you should enclose the table in [] - in fact it's usually easier to just do that all the time.

  7. #7
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Re: missing operator error

    ok thanks! i'll bear this in mind for future applications

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: missing operator error

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0