Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    513

    logical operator as a variable (syntax?)

    I've got a bit of a wacky condition (has to do with an inherited mess..)
    I need to make to operator in an if statement variable, and could use some help with getting the syntax correct:

    so it would go like this (or so I thought), but it "seems" to be wreaking havoc to the for next loop that it's nested in...


    I'm getting a "next without for" error

    Code:
    For Each tdf In dbs.TableDefs 'loop thru all of the tables in the project
    
                ' Relink connected tables for only the type of backend file being relinked
                If vlinktype = tbl Then
                      If Left(tdf.Name, 3) <> "tbe" Then
                Else
                      If Left(tdf.Name, 3) = "tbe" Then
                End If
    
                .... large block of code
    
                     end if
    
    Next tdf
    many thanks in advance,
    mark

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    What does 'wreaking havoc' mean - error message, wrong results, nothing happens?

    Have you step debugged?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Your if-then-else code is not making sense - you don't have enough End If lines. This is the cause of the "next without for" error - even though you have it is the code, Access is confused.

    You don't need both checks on
    Left(tdf.Name, 3)

    If one of them is not true, then obviously the other one is true.

    It is not clear from your code the conditions required for the "large block of code" to be executed.

    Can you clarify, please?
    Last edited by John_G; 03-08-2015 at 11:14 PM. Reason: clarify the post

  4. #4
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    513
    OK.... so wreaking havoc is a exaggeration..
    the code won't compile on opening; I get an error " "next without for" -however, there is a "for"; I can see how access is confused by code in question

    it may be a clearer question if I asked: can I pass an operator (to an if statement) as a variable?

    depending on where the code was called, the operator would be EITHER an "=" or "<>"

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Never tried that. Might require Eval() function.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    513
    thanks... but that didn't work; i think I simply need to rethink the organization / logic of the code

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Syntax error (missing operator)
    By aamer in forum Access
    Replies: 5
    Last Post: 09-25-2014, 07:36 PM
  2. Replies: 9
    Last Post: 01-22-2013, 04:23 PM
  3. Operator / Syntax failure in coding
    By karmacable in forum Programming
    Replies: 6
    Last Post: 09-22-2011, 04:37 PM
  4. Syntax error missing operator(3075)
    By parisienne in forum Programming
    Replies: 1
    Last Post: 04-07-2011, 02:29 PM
  5. Syntax Error...missing operator
    By jgelpi16 in forum Programming
    Replies: 14
    Last Post: 09-09-2010, 11:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums