+ Reply to Thread
Results 1 to 6 of 6

Help on Error message when no results found

  1. #1
    Forum Contributor
    Join Date
    01-21-2015
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    116

    Help on Error message when no results found

    Hi

    I have some code that searches a few columns and if a match found puts the results in a list box. All works as expected if the search matches data, however if it does not match it throws up a Runtime 1004 error message. How can I put a message box up saying no results and on pressing ok clears the form (Sub Clear_form)

    This is the line that Debug brings up the error on.

    Please Login or Register  to view this content.
    Attached is the workbook

    TEST.xlsm

    Thanks

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Help on Error message when no results found

    You may try something like this.....

    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Forum Contributor
    Join Date
    01-21-2015
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    116

    Re: Help on Error message when no results found

    Dear sktneer

    Thank you that works a treat except I can't get the focus back to textbox1 after acknowledgment of error message. I normally use.

    TextBox1.SetFocus

    Any Ideas? I know I can use the mouse but ideally want to start the form again with blank with all reset.

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Help on Error message when no results found

    What about putting the code in the "Show" button click event?

    Please Login or Register  to view this content.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  5. #5
    Forum Contributor
    Join Date
    01-21-2015
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    116

    Re: Help on Error message when no results found

    Also, great thank you.

  6. #6
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Help on Error message when no results found

    Thanks for the rep. points.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Reset form on no results found (Runtime error)
    By chrisandsally in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2015, 03:09 PM
  2. [SOLVED] return an error if not found, or a message
    By freshfruit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2014, 02:17 PM
  3. [SOLVED] Alternative message box instead of run time error 1004 box no cells were found
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-05-2013, 04:26 AM
  4. [SOLVED] Run Time Error Message 1004 : No Cells were found
    By brajpalshishodia in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-15-2012, 12:52 PM
  5. Error in Filter Macro when no results found
    By aravindhan_31 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-13-2012, 08:51 AM

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