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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling errors from updating views

Status
Not open for further replies.

EMJULIAN

Programmer
Aug 14, 2002
45
US
I am using a view that users are entering data into. There is a possibility that all the fields in the table will be exactly the same and when the table updates I get an error (The key defined for the KeyField property for table is not unique). What I'd like to do is figure out how to check this before it updates the table and put in my own message (warning, duplicate entry), or keep the table from updating that record without losing all the other records, which is what I think will happen if I do a tablerevert(), right?? Any thoughts on the easy way to do this or where to check the entries before it gets update?

Thanks!
Eve
 
How is the data being entered in (i.e. Textboxes, grid, etc.)? Perhaps a simple solution would be to use the locate command. For example:


lcSrchStr = ThisForm.MyTxt.Value

Select MyTable

Locate for KeyID = Val(lcSrchStr) && KeyID being the field in table

IF Found() Then
MessageBox("You Have Entered a Duplicate Value")
Thisform.MyTxt.Value = ""
ThisForm.MyTxt.SetFocus()
NoDefault
Return .f.
Else
***TableUpdate Code***
EndIf




Hope This helps.


-Kevin
 
The entry is through a grid. To be honest I'm not even sure when the table is updating - it's all kind of smoke and mirrors as far as I can tell. Would I use this code in the lost focus of the grid or someplace else??

Thanks!
eve
 
I would use a textbox inside the grid and use the code in the lost focus event of the textbox.

-Kevin

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top