Results 1 to 4 of 4
  1. #1
    orcinus is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    67

    NOT LIKE or LIKE NOT

    Just trying to play with some code to learn about collections and other apparently the LIKE NOT operator or whatever is supposed to be the equivalent of the NOT LIKE in a query.

    I say "supposed" because at this point I don't know what the equivalent is because the results I get are ambiguous.

    The below code is supposed to iterate through the tables in my database, which it does, IF I replace the statement:

    If T.Name Like Not "msys*" Then etc..
    with
    If T.Name Like "msys*" Then etc.. (only returns all tables which start with msys)

    The LIKE NOT operator gives an error: datatype mismatch, so...

    I guess my question is, what is the appropriate syntax for NOT LIKE? LIKE NOT doesn't appear to be it. I get an error when using this. I can't find anything else in HELP or online for that matter.

    Note, obviously I'm trying to exclude the Sys Tables from my results. There may be another way to do this, but I as I stated in the beginning, this is more an exersize in applying some principles.

    Any help is appreciated..!


    Dim db As DAO.Database


    Dim strTblName As String
    Dim T As TableDef
    Dim msystbl As String
    Set db = CurrentDb

    For Each T In db.TableDefs
    If T.Name Like Not "msys*" Then
    strTblName = strTblName & vbCrLf & T.Name
    End If
    Next
    MsgBox strTblName
    End Sub

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Hi

    I'm not sure if this is what you're looking for, but it does work
    Code:
     
    For Each T In db.TableDefs
    If Not T.Name Like "msys*" Then
    strTblName = strTblName & vbCrLf & T.Name
    End If
    Next
    MsgBox strTblName
    End Sub
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    orcinus is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    67
    Quote Originally Posted by Bob Fitz View Post
    Hi

    I'm not sure if this is what you're looking for, but it does work
    Code:
     
    For Each T In db.TableDefs
    If Not T.Name Like "msys*" Then
    strTblName = strTblName & vbCrLf & T.Name
    End If
    Next
    MsgBox strTblName
    End Sub
    Yes, this works. Looks like this was the syntax I was looking for..thanks!

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Glad to help.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

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