+ Reply to Thread
Results 1 to 9 of 9

Replacing run time error message with a different message

  1. #1
    Registered User
    Join Date
    03-26-2007
    Posts
    92

    Replacing run time error message with a different message

    Hello -

    I've attached an example of the spreadsheet I'm working on. If you click the "Request Part" button, you will get a pop up box asking you to select a category. From the drop down, select Accessories. You will get a new pop up asking you to enter a part number, the quantity, and who it was requested by. The list is pulled from a worksheet labeled "AccessoryLookupList". If the part added is on that list, I don't have any problems at all with my spreadsheet. However, if a person tries to add a part that is not on the list, I get a runtime error. I know why the error happens, but instead of getting an Excel error pop up, I'd like to have a "Part not found" message box pop up. I'm not sure how to implement this.

    Thank you for the help!
    Attached Files Attached Files
    Last edited by penny; 12-11-2009 at 01:24 PM.

  2. #2
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Replacing run time error message with a different message

    Hi Penny

    Put the following code in Private Sub cmdAccAdd_Click():

    Please Login or Register  to view this content.
    Dion

  3. #3
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Office 2003 / Office 2007
    Posts
    114

    Re: Replacing run time error message with a different message

    Just some pseudocode to get you started here:

    Please Login or Register  to view this content.
    Run the code, create the error, then sub in that error number for "error" and handle that error with your custom msgbox.

  4. #4
    Registered User
    Join Date
    03-26-2007
    Posts
    92

    Re: Replacing run time error message with a different message

    Quote Originally Posted by mojo249 View Post
    Hi Penny

    Put the following code in Private Sub cmdAccAdd_Click():

    Please Login or Register  to view this content.
    Dion
    Perfect, thank you for the quick response!

  5. #5
    Registered User
    Join Date
    03-26-2007
    Posts
    92

    Re: Replacing run time error message with a different message

    I ran into an issue; I'm not sure if it's my issue or something with the code from mojo249.

    I have some part numbers that start with "11". Whenever I try to select a part number that starts with "11", it tells me the part number is not valid, even though they do indeed match.

    I have no idea why this is happening.

  6. #6
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Office 2003 / Office 2007
    Posts
    114

    Re: Replacing run time error message with a different message

    Just a guess, the code provided uses a named range so if the part was added OUTSIDE of the named range then it would not be "valid". If the named range used for validation is for example A1:A100, and the new element is in A101 then you need to simply expand the named range.

  7. #7
    Registered User
    Join Date
    03-26-2007
    Posts
    92

    Re: Replacing run time error message with a different message

    The range is a dynamic range, so that shouldn't be causing the issue. The code works fine when I'm using a part number that is a mix of numbers and letters. If it's all numbers and starts with "11" I'm running into an issue. Does it have something to do with how the
    Please Login or Register  to view this content.
    and the
    Please Login or Register  to view this content.
    are formatted?

  8. #8
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Replacing run time error message with a different message

    Hi Penny

    What's the error message you're receiving?

    Dion

  9. #9
    Registered User
    Join Date
    03-26-2007
    Posts
    92

    Re: Replacing run time error message with a different message

    Quote Originally Posted by mojo249 View Post
    Hi Penny

    What's the error message you're receiving?

    Dion
    Hello Dion -

    When it happens, I get my message box note.
    Please Login or Register  to view this content.

+ 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