Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb6 intercepting a constraint

Status
Not open for further replies.

moki

Programmer
Dec 5, 2000
37
0
0
Is there a way to intercept constraint and/or trigger messages before it is displayed to the user.

Example: Oracle Database field Last_Name Varchar2(25) Not Null.

The user leaves the row before entering the Last_Name.

In this case I would like to replace the constraint message displayed: ORA-01400: Cannot insert Null into ("Schema.TableName.Last_Name") with a messsage such as "The Last Name field must have a value.

Thank you in advance.

 
Moki,

Im going to guess that when you say the client leaves a "ROW" you working with some sort of datagid. If this is so you can use a lostfocus, beforeupdate, or a onchange method to catch the data before it hits ORA.
 
Dashley,

Thanks for the response.

I was hoping to avoid programming in an edit. Would rather have ORA catch the error but would like to modify the message it displays to a more user friendly one.

Don't know if this is even possible....Thanks...
 
Use VB error handling.

On Error GoTo HandlMyError

'... Code to do whatever

Exit Sub 'Or Function

HandleMyError:
If Err.Number=TheErrorNumberFromORA Then
MsgBox "Display Your Message Here"
End If
 

MsgBox Err.Description

can also be used.

------------------------------------------
The faulty interface lies between the chair and the keyboard.
 
Err.Description will display the error description from Oracle, which is excactly what the original poster did not want.
 
Thank you 'experts'.

bjd4jc, found that by using the error handler in the datagrid error event did the trick.

Thanks again all...
 
Oh, i am sorry, but somehow I got the idea that he wanted to display a more technical error message.

I always use a public function in a module, where a select case structure is used to display user friendly error messages. In your err handler, call the function with err number as argument, and the function will take care of all the errors. It is also easy to update, because you only have one place where you need to change code.

------------------------------------------
The faulty interface lies between the chair and the keyboard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top