|
-
Mar 20th, 2003, 04:21 PM
#1
Thread Starter
Lively Member
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?
-
Mar 20th, 2003, 04:50 PM
#2
Don't put them on the same line.....
-
Mar 21st, 2003, 11:09 AM
#3
Thread Starter
Lively Member
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!
-
Mar 21st, 2003, 11:14 AM
#4
Frenzied Member
do you have a "Exit Function" before "Fix:" ?
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Mar 21st, 2003, 11:19 AM
#5
Fanatic Member
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:
on error goto Fix:
Exit Function '(Or sub)
Fix:
data1.Recordset.CancelUpdate
MsgBox "If a field is not filled in please enter N/A. This Record will not be saved", vbExclamation
Exit Function '(Or sub)
My usual debug message:
VB Code:
Msgbox Err.Description, , "Error #" & Err.Number
-
Mar 21st, 2003, 11:26 AM
#6
Thread Starter
Lively Member
-
Mar 21st, 2003, 11:35 AM
#7
Thread Starter
Lively Member
-
Mar 21st, 2003, 11:59 AM
#8
Thread Starter
Lively Member
the msgbox comes up regardless of whether there is an error or not!
-
Mar 27th, 2003, 03:05 PM
#9
Fanatic Member
Now now...
Originally posted by lfc1lfc
the msgbox comes up regardless of whether there is an error or not!
There,
VB Code:
on error goto Fix: '>ON TOP OF CODE
'>YOUR OTHER CODE (...)
'>YOUR OTHER CODE (...)
'>YOUR OTHER CODE (...)
'>YOUR OTHER CODE (...)
'>YOUR OTHER CODE (...)
Exit Function '(Or sub) 'What I think >YOU FORGOT<
Fix:
data1.Recordset.CancelUpdate
MsgBox "If a field is not filled in please enter N/A. This Record will not be saved", vbExclamation
Exit Function '(Or sub)
is everything ok now? Dont freak out on me !!!
-
Mar 27th, 2003, 03:16 PM
#10
Frenzied Member
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)
-
Mar 28th, 2003, 05:51 PM
#11
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|