+ Reply to Thread
Results 1 to 6 of 6

error handler label not defined.

Hybrid View

Rob K error handler label not... 06-17-2015, 05:59 AM
Norie Re: error handler label not... 06-17-2015, 06:32 AM
Rob K Re: error handler label not... 06-17-2015, 08:27 AM
Rob K Re: error handler label not... 06-17-2015, 06:38 AM
Norie Re: error handler label not... 06-17-2015, 06:47 AM
Norie Re: error handler label not... 06-17-2015, 09:27 AM
  1. #1
    Forum Contributor
    Join Date
    02-16-2012
    Location
    London, England
    MS-Off Ver
    Excel mac 2011
    Posts
    238

    error handler label not defined.

    hi Guys,

    I think this should be fairly obvious what I'm trying to do here, but I can't for the life of me understand the error.

    Private Sub Lastfind_Click()
        On Error GoTo ErrorHandler
        QiForm.PartFind = MySearch
        Module1.Find_Part
        
    ErrorHandler:
        MsgBox "Can only unclear last search just cleared"
        Resume UserForm_Initialize
        
    End Sub
    Basically, if it can't find last find, not a problem just re initialize the form again. I could use an if statement for this, but I wanted to learn about error handling.

    What does it mean by label if Userform_initialize is not one? Please help to get this working. I'm suspecting a syntax error, but I can't find anything on google that addresses this problem

    Kind regards

    Rob

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: error handler label not defined.

    Rob

    This is a label.
    ErrorHandler:
    Userform_Initialize is the name of a sub.

    What are you actually trying to do and what error are you trying to handle?

    That really isn't clear from the posted code, especially since all it appears to do is call other code.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    02-16-2012
    Location
    London, England
    MS-Off Ver
    Excel mac 2011
    Posts
    238

    Re: error handler label not defined.

    This is for part number inspection. so I have a userform to enter the inspection request and the data entered populates two sheets in various ways. There is then another button for the quality inspection, here the part number in question is searched for to see if it is already on watch, if so, it pulls up the record and if not it clears it again. That all works fine, so I wanted to put a go back button on so they can recall the last search again if it clears for whatever reason, and that worked really well. The bug comes in when it is clicked when you just open up the form and there is nothing to search for, so I thought that this would be a good time for it to just skip over the error message and re initialize the form ready for the next search.

    It seems to me though that a simple if statement will solve the problem as the error handling is actually now taking up about 3 times as much code to get past an infinite loop that has now cropped up as a result.

    The latest is that I have that working now, but the button now no longer works. I'm starting to think this is a waste of time. It looked so simple in the tutorial I read.

  4. #4
    Forum Contributor
    Join Date
    02-16-2012
    Location
    London, England
    MS-Off Ver
    Excel mac 2011
    Posts
    238

    Re: error handler label not defined.

    Ah, ok,

    I have a form that will search for a part number, if it finds it it will pull up data, if it can't find it I want it to go to the UserForm_Initialization sub, which starts from a blank sheet but I have no easy way of finding a line number for this and the go to statement seems to ask for it.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: error handler label not defined.

    How is the user entering the part number and how are you searching for it?

    Also, why do you want to call the Initialize event if the part number isn't found?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: error handler label not defined.

    Can you upload a sample workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

+ 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] Need error handler code to avoid pivot table refreshing error if no data is available
    By adelkam in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2015, 12:37 PM
  2. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  3. [SOLVED] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  4. [SOLVED] Run Time 1004 - App Defined or Object defined error with String defined path structure
    By sarails in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-11-2012, 09:38 PM
  5. [SOLVED] Macro error - Run time error 1004 (App defined/Object Defined error)
    By jlax34 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-06-2012, 03:02 PM

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