Intercept Error 
Author Message
 Intercept Error

When the user wants to add a record, do a form which  gets the record
information.  When the user presses "OK", I do an append blank, then a
replace for each of the fields.  I have a field part_no which is a primary
key.  If this primary key already exists, I need to be able to intercept the
uniqueness violation error in foxpro and run my own error handler.  I come
from a C background and am new to fox, so any "detailed" help would be
greatly appreciated.  I read about ON ERROR but because I am using the click
method for the OK button, I'm not sure where to put the code for the error
handling procedure or if ON ERROR is the best way to handle this.
:-)

Thanks
--
Chris Bernholt

s002ccbatdiscover.wrightedu



Sun, 27 Aug 2000 03:00:00 GMT  
 Intercept Error

Chris,

First, welcome to the FoxPro world! It's a much better place than the C/C++ world *g* (I
can say that because they are two of the languages I use)

Second, Every class in VFP has an Error() method which can be used to trap errors. It is
generally recommended that you derive a set of subclasses from the VFP BaseClasses and use
your subclasses for all of the classes/objects you create.

Third, you should look at using an unique integer key field that the enduser never sees
for your PK in every table and not rely on (force) your user to create unique keys. If you
want to prevent duplicate entries of fields you can make the index Candidate.

Fourth, with the native data buffering, updateable views, TableUpdate(), TableRevert() and
transactions you really don't need to code "replaces" any more, bind the controls to the
table fields, append blank to add a new record, then if the user saves the work issue a
TableUpdate() if they want to cancel the changes TableRevert().

df    - (Microsoft FoxPro MVP) http://www.geocities.com/ResearchTriangle/9834/

Quote:

>When the user wants to add a record, do a form which  gets the record
>information.  When the user presses "OK", I do an append blank, then a
>replace for each of the fields.  I have a field part_no which is a primary
>key.  If this primary key already exists, I need to be able to intercept the
>uniqueness violation error in foxpro and run my own error handler.  I come
>from a C background and am new to fox, so any "detailed" help would be
>greatly appreciated.  I read about ON ERROR but because I am using the click
>method for the OK button, I'm not sure where to put the code for the error
>handling procedure or if ON ERROR is the best way to handle this.



Sun, 27 Aug 2000 03:00:00 GMT  
 Intercept Error

There is an excellent article on VFP error handling at www.stonefield.com

--
Craig Berntson
Microsoft Fox MVP
Salt Lake City Fox User Group

Quote:

>When the user wants to add a record, do a form which  gets the record
>information.  When the user presses "OK", I do an append blank, then a
>replace for each of the fields.  I have a field part_no which is a primary
>key.  If this primary key already exists, I need to be able to intercept
the
>uniqueness violation error in foxpro and run my own error handler.  I come
>from a C background and am new to fox, so any "detailed" help would be
>greatly appreciated.  I read about ON ERROR but because I am using the
click
>method for the OK button, I'm not sure where to put the code for the error
>handling procedure or if ON ERROR is the best way to handle this.
>:-)

>Thanks
>--
>Chris Bernholt

>s002ccbatdiscover.wrightedu




Sun, 27 Aug 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Intercepting error messages from SQL Server?

2. Intercepting form close and appl close

3. intercepting keyboard strokes

4. How to intercept Mouse events for the columns ?

5. How to intercept ie4's OnQuit or any event ?

6. Timer in a Toolbar intercepting a Form's return value?

7. How to intercept a keyboard in external fox application ?

8. Error 1958 Error loading printer driver.

9. Internal consistancy error(error 1000)

10. Connectivity error:[Microsoft ODBC Driver Manager]Function sequence error

11. Error message "Virtual Function Error"

12. Unable to process error, Unknown error code

 

 
Powered by phpBB® Forum Software