Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: multiple error handler fail in form image properties

  1. #1
    Board Regular
    Join Date
    Jan 2015
    Location
    Hungary, Budapest
    Posts
    244
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default multiple error handler fail in form image properties

    Hi guys i have this:
    Code:
    Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)Application.ScreenUpdating = False
    On Error GoTo kov 'I need this error handler becasue some users are not macro friendly.... :)
    ActiveSheet.ShowAllData
    kov:
    Cells.Find(What:=ComboBox1.Value, After:=Range("C10"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
    aclr = ActiveCell.Row - 10
    '...
    'load a barrowful of data from sheets into form textbox
    '...
    
    On Error GoTo 0 'tried with this and w/o this not helped
    
    
    On Error GoTo pacikaki 'this error handerdont want to work
    Me.Image1.Picture = LoadPicture("some intranet address" & ComboBox1.Value & ".jpg")
    CreateObject("WScript.Shell").Popup TextBox2.Value & " adatai beolvasva", 1, "Info"
    Exit Sub
    
    
    pacikaki:
    MsgBox ("hiba a képpel, szinte képtelenség!")
    CreateObject("WScript.Shell").Popup TextBox2.Value & " adatai beolvasva", 1, "Info"
    
    
    End Sub
    The picture loading is working if the picture is present in the given directory, but if its not the "On Error GoTo pacikaki" is not going to "pacikaki"
    I would like some help from you, what m i missing?

    Cheers

  2. #2
    MrExcel MVP
    Join Date
    Dec 2008
    Location
    Phoenix, Arizona
    Posts
    6,154
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: multiple error handler fail in form image properties

    At least in that last bit that you asked about, it looks to me as though you simply want to pass over the error if there is one (with a message box advising). If that is the case, try:

    On Error Resume Next
    Me.Image1.Picture = LoadPicture("some intranet address" & ComboBox1.Value & ".jpg")
    If Err.Number = 53 Then
      MsgBox ("hiba a képpel, szinte képtelenség!")
    End If
    On Error GoTo 0

    CreateObject("WScript.Shell").Popup TextBox2.Value & " adatai beolvasva", 1, "Info"


    I would suggest reading/studying: On Error WTF? | Excel Matters

    Hope that helps,

    Mark

  3. #3
    Board Regular
    Join Date
    Jan 2015
    Location
    Hungary, Budapest
    Posts
    244
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: multiple error handler fail in form image properties

    Quote Originally Posted by GTO View Post
    Code:
    On Error Resume Next
    Me.Image1.Picture = LoadPicture("some intranet address" & ComboBox1.Value & ".jpg")
    If Err.Number = 53 Then
      MsgBox ("hiba a képpel, szinte képtelenség!")
    End If
    On Error GoTo 0
    CreateObject("WScript.Shell").Popup TextBox2.Value & " adatai beolvasva", 1, "Info"
    Not worked, but used the on error goto -1 and now its do what i wanted, the final code
    Code:
    ....
    On Error GoTo -1
    On Error GoTo kephiba
    Me.Image1.Picture = LoadPicture("some intranet address" & ComboBox1.Value & ".jpg")
    On Error GoTo 0 'maybe this is not even needed now
    CreateObject("WScript.Shell").Popup TextBox2.Value & " adatai beolvasva", 1, "Info"
    Exit Sub
    kephiba:
    Me.Image1.Picture = LoadPicture("")
    MsgBox ("hiba a képpel, szinte képtelenség!")
    End Sub
    Thank you GTO!
    Last edited by CsJHUN; Jun 20th, 2016 at 04:34 AM.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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