Results 1 to 3 of 3

Thread: [RESOLVED] Search Database

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    142

    Resolved [RESOLVED] Search Database

    Hello, I am trying to create a search function for the phone number in my database, but i used a space in phone number. So now its name is [phone numb.]
    I want to know how to refer to it in the filter cell in query builder. -- LIKE @phone numb. + '%' -- doesn't work. And nothing else I have tried.
    Thanks in advance.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Search Database

    You should never have a field name with spaces/punctuation/etc in, because there are various situations where it causes problems - some of them to the point where you cannot use that field/table, as there is no way to 'fix' it (and this could well be one of them).

    Unless you have an extremely good reason for having the name like that (making things 'easier' is not a good reason, and probably not even true), change it to something else, eg: PhoneNumber


    For more information, see the article What names should I NOT use for tables/fields/views/stored procedures/...? from our Database Development FAQs/Tutorials (at the top of the Database Development forum)

  3. #3
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: Search Database

    Quote Originally Posted by ikdekker View Post
    Hello, I am trying to create a search function for the phone number in my database, but i used a space in phone number. So now its name is [phone numb.]
    I want to know how to refer to it in the filter cell in query builder. -- LIKE @phone numb. + '%' -- doesn't work. And nothing else I have tried.
    Thanks in advance.
    Not using spaces in column names aside it doesn't matter what you have in the variable set up as far as spaces in the column are concerned. Something like this should work. Of course what the data looks like does matter.

    "where [phone numb] like '" & @phone & "%'"

    Assuming @Phone has the number you are looking for and it is formatted to match what is stored in the database.

Posting Permissions

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



Click Here to Expand Forum to Full Width