+ Reply to Thread
Results 1 to 12 of 12

Debug errors using my search function

  1. #1
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Debug errors using my search function

    I have come across an issue with my database search query.

    I have a field in my table set as text because I want to use numbers and/or letters in the values I enter into it.

    When I try searching for a numeric value that I know is listed in the table I get a debug error as follows:
    Runtime error "3464" Data type mismatch in criteria expression

    When I try searching for the value that is letters only I get debug error as follows:
    Rumtime error "2001" You cancelled the previous operation.



    This is the code
    The me.volume section of the code is the field that the code refers to.
    the dCount section of the code is where the debug highlight appears

    Please Login or Register  to view this content.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Debug errors using my search function

    What is this line for:

    Please Login or Register  to view this content.
    ?

    If you are searching for data formatted as text, the entire phrase that you are searching for needs to be surrounded by single quotes.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: Debug errors using my search function

    To be perfectly honest I don't know exactly what that line does.
    The code was provided by someone here helping me out.

    I never had to surround anything I was searching for with quotes before, for example when using the search function to search for a title (no single qts reqd - the search works fine without them).

    The only thing that is different now is that I changed the data type for the volume part of the table to text so that it can contain both numbers or letters.
    This has then caused the errors as detailed above.

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Debug errors using my search function

    Which field did you change to text, Volume, Movie Title, or Rating? I'd guess Volume. If so, change this:

    Please Login or Register  to view this content.
    to this:

    Please Login or Register  to view this content.
    btw, the line I asked about before was to clear the trailing " AND " from the criteria statement.

  5. #5
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: Debug errors using my search function

    ah ok I see ....

    yes it was the volume field that changed to text. Will try the code change and post back.

  6. #6
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: Debug errors using my search function

    Made the change as instructed and the searching seems to be working except for one small problem.

    Now when I do a volume search it is not recognising a partial search criteria - for example if I have a volume labelled Prog13 - doing a search just for P or Pro or 13 will popup the "no search results" msgbox instead of returning the partial results as it should.

    I have checked my query and it is definitely setup with "like" search criteria however I wonder of the search button code is causing this somehow ?

  7. #7
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Debug errors using my search function

    I wouldn't really be able to tell ya as the code you've posted above doesn't contain your query. Maybe mark this solved and start a new thread to look at the query?

  8. #8
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: Debug errors using my search function

    well thats the thing tho .... I don't think it is the query because that hasn't changed ... the query and search was working fine until I changed the data type to text.

    The query contains search criteria that uses "like" to match partial criteria.
    The query is the same for the other 2 fields and they both work as expected.

    The problem I am facing now only started after I changed the data type to text for the volume field.
    I didnt make any changes to the actual query at all.

  9. #9
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Debug errors using my search function

    Right, but you may need to make changes to the query because the data type has changed. To be honest, I'm not sure how you would have used the Like operator with a date field. However, usually dates need to be surrounded with pound signs (#) in a query. If that is changing to text, you will need single quotes instead.

  10. #10
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: Debug errors using my search function

    Quote Originally Posted by davegugg View Post
    Right, but you may need to make changes to the query because the data type has changed. To be honest, I'm not sure how you would have used the Like operator with a date field. However, usually dates need to be surrounded with pound signs (#) in a query. If that is changing to text, you will need single quotes instead.
    NOt a date field ... Just a data field.

    OK will have to have a look at it again.

    Question though,

    If I have search criteria in my button code do I actually NEED a query setup in the database itself ?


    I tried deleting the query and have found that I do indeed still require the query to be there.
    Last edited by vampyr07au; 05-26-2011 at 10:05 PM. Reason: more info

  11. #11
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Debug errors using my search function

    It looks to me like your button checks whether the user has filled out all the information the query needs to run. If there is enough, the form will be opened to display the results. The query must run on the "search results" form open event.

  12. #12
    Registered User
    Join Date
    11-07-2009
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    79

    Re: Debug errors using my search function

    Quote Originally Posted by davegugg View Post
    It looks to me like your button checks whether the user has filled out all the information the query needs to run. If there is enough, the form will be opened to display the results. The query must run on the "search results" form open event.

    Yes thats about right .... when the button is clicked the search results are displayed based on the information provided.

    The problem is ... as I said ... that it's supposed to be able to match partial search strings not just complete ones .... and it's suddenly stopped doing that now.
    It still does it for the title field and the rating field just not the volume field since the change was made as above.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1