On 12/30/2014 11:50 PM, Christian e Ana Luiza Britto wrote: > Hi Folks, > First I would like to wish to you all a Happy New Year! > After that, I would like to know how to use the DataSource Before > Delete event to verify if a record can be deleted or not. If not the > record cannot be deleted the program must keep the record intact. > Best Regards, > Christian
Greetings Christian, Normally you should not need to test if a record can be deleted or not. DataSource.Remove will handle that automatically and report a success or failure. If the record could not be deleted, it would, of course, still remain intact. So, I am not really sure what you are asking for. Now there may be application-specific circumstances where certain records may need to be protected. In that case, the question to ask would be, "What, in *your* application determines whether or not a record can be deleted?" Working with a slightly modified version of the Database Sample, I've added the BeforeDelete event subroutine and an application-specific test subroutine. Public Sub DataSource1_BeforeDelete(Keys As Variant[]) If RecordProtected(Keys[0]) Then Stop Event Endif End Public Sub RecordProtected(Key As Variant) As Boolean Dim rRecordSet As Result rRecordSet = DataSource1.Connection.Exec("select `firstname` from `test` where `id`=" & Key) If rRecordSet["firstname"] = "Pierre" Then 'Do not delete any of Pierre's records Print "Pierre's records are protected!" Return True Endif Return False End HTH, Lee __________ "Artificial Intelligence is no match for natural stupidity." ------------------------------------------------------------------------------ Dive into the World of Parallel Programming! The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user