Results 1 to 6 of 6
  1. #1
    7Iron_707 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    4

    Help


    I use the following to select records and it works fine until I add a 3rd "or", what am I doing incorrectly?....Thank you, it is driving me bonkers

    Private Sub command555_Click()
    Dim strsearch As String
    Dim strText As String
    strText = Me.TxtSearch.Value
    strsearch = "SELECT * from Ewing_Folks_Master where ((AncesName like ""*" & strText & "*"") or (Kit like ""*" & strText & "*"") or (Real Name like ""*" & strText & "*""))"
    Me.RecordSource = strsearch
    End Sub
    if I remove the red it works just fine and searches two fields and returns all records containing the string that is found in eiter field, but when I "look" into a 3rd field I get the following

    Run-time error '3075':

    Snytax error (missing operator) in query expression '((AncesName like "*tes*" or (kit like "*tes*") or (Real Name like "*tes*"))'.


    tes is the string that i put into the TxtSearch field as the value to look for

    Thank you

    dg

    dgClick image for larger version. 

Name:	form.png 
Views:	27 
Size:	62.2 KB 
ID:	42099
    Last edited by 7Iron_707; 06-07-2020 at 08:41 AM. Reason: added form view

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Since your field name has a space in it you have to surround the name with square brackets [Real Name]. In the future id recommend not to use spaces or any special characters in your field names or any object names.

  3. #3
    7Iron_707 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    4
    wow, you are my hero...and I am following your recommendation(s) to the "letter"

    thank you !!!

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Go farther. Do not begin an object name with a number. Adopt a naming convention - command555. What will such names mean to you when you need to review the code 6 months later? Not much. It will also prevent you from using a reserved name if you do so. I'd say the chance of that will be zero if you adopt a naming convention for all objects and variables as well.
    Naming conventions
    - http://access.mvps.org/access/general/gen0012.htm
    - https://www.access-programmers.co.uk...d.php?t=225837

    What not to use in names
    - http://allenbrowne.com/AppIssueBadWord.html
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    7Iron_707 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    4

    Help Again.

    Quote Originally Posted by kd2017 View Post
    Since your field name has a space in it you have to surround the name with square brackets [Real Name]. In the future id recommend not to use spaces or any special characters in your field names or any object names.
    kd2017, you solved my last problem and now I am in trouble again.

    I copied the key word search form and changed the input table and relative fields. Now my search doesn't work, I have a button command555 to search and a button command79 to return back all the records after I use the command555 to select a strText. I know this is going to be either really easy/dumb or very technical/difficult....I never have mediocre problems...btw they are usually are of the easy and dumb type.

    I think that the only thing that i did to the code below is changed the from table to: DNA Matchlist Bro_Sis, and change the field [real name] to realname as that is the named of the field in the table.

    now when I click command555 or the command79, I receive a "run-time error 3131, Syntax error in from clause" and when click the debug it takes me to the code with the Me.Recordsource = strsearch yellowed

    Thanks for helping

    dg

  6. #6
    7Iron_707 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    4
    Geez, I just figured it out....if tables have spaces us brackets....just like you told me on fields....dugh..

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