Results 1 to 11 of 11

Thread: Error Handling

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    70

    Error Handling

    I have this error handling statement:

    on error goto fix:

    fix: data1.Recordset.CancelUpdate

    on the same statement i.e. fix I want to add this:

    MsgBox "If a field is not filled in please enter N/A. This Record will not be saved", vbExclamation

    I want this to come up along with CancelUpdate, but when I put it on the same line as data1.Recordset.CancelUpdate, I get a message saying "Expected end of statement"

    Is there a way of doing what I want to do?

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Don't put them on the same line.....
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    70
    But if i put it on the next line this:

    MsgBox "If a field is not filled in please enter N/A. This Record will not be saved", vbExclamation

    happens regradless of whether a field is filled in or not. I don;t want that to happen!

  4. #4
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    do you have a "Exit Function" before "Fix:" ?

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  5. #5
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    Re: Error Handling

    Originally posted by lfc1lfc
    I have this error handling statement:

    on error goto fix:

    fix: data1.Recordset.CancelUpdate

    on the same statement i.e. fix I want to add this:

    MsgBox "If a field is not filled in please enter N/A. This Record will not be saved", vbExclamation

    I want this to come up along with CancelUpdate, but when I put it on the same line as data1.Recordset.CancelUpdate, I get a message saying "Expected end of statement"

    Is there a way of doing what I want to do?
    VB Code:
    1. on error goto Fix:
    2.  
    3.  
    4. Exit Function '(Or sub)
    5.  
    6. Fix:
    7. data1.Recordset.CancelUpdate
    8. MsgBox "If a field is not filled in please enter N/A. This Record will not be saved", vbExclamation
    9. Exit Function '(Or sub)

    My usual debug message:

    VB Code:
    1. Msgbox Err.Description, , "Error #" & Err.Number

    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    70
    thanks guys!

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    70
    IT STILL DOESN'T WORK!

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    70
    the msgbox comes up regardless of whether there is an error or not!

  9. #9
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    Now now...

    Originally posted by lfc1lfc
    the msgbox comes up regardless of whether there is an error or not!
    There,

    VB Code:
    1. on error goto Fix: '>ON TOP OF CODE
    2.  
    3. '>YOUR OTHER CODE (...)
    4. '>YOUR OTHER CODE (...)
    5. '>YOUR OTHER CODE (...)
    6. '>YOUR OTHER CODE (...)
    7. '>YOUR OTHER CODE (...)
    8.  
    9. Exit Function '(Or sub) 'What I think >YOU FORGOT<
    10.  
    11. Fix:
    12. data1.Recordset.CancelUpdate
    13. MsgBox "If a field is not filled in please enter N/A. This Record will not be saved", vbExclamation
    14.  
    15. Exit Function '(Or sub)

    is everything ok now? Dont freak out on me !!!

    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

  10. #10
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    Why don't you post your code so we can see what you're doing?

    (don't forget to put [vbcode][/vbcode] tags around your code when you post)
    ~seaweed

  11. #11

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    70
    I did miss out the Exit Sub but I solved the problem quite a few days ago. Thanks for your help anyway.

    I have a another query regarding how to add the records of a field to a listbox. I've already posted a thread and was hoping you would have a look at it. (In database section)

    thanks!

Posting Permissions

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



Click Here to Expand Forum to Full Width