Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sometimes deletes and sometimes does not
Message
From
06/10/2004 16:58:16
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
06/10/2004 04:35:46
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00949061
Message ID:
00949359
Views:
13
First of all, if you delete a record, you need to go to another record. Visual FoxPro will not do this automatically. So, the typical code to delete a record, and then show the next valid record, might be more or less like this:
delete
skip
if eof()
  go bottom
endif
ThisForm.Refresh()
Second, the DELETE can fail, if you use triggers. Triggers are automatically created if you use referential integrity.

The best way to handle this is with buffering. Buffering also allows you to undo changes done by the user. The above code might be improved as follows:
delete
if not TableUpdate()
  MessageBox("Can't delete the record.")
else
  skip
  if eof()
    go bottom
  endif
  ThisForm.Refresh()
endif
This is typical code for deleting a record in the table which the user is currently viewing. If you want to delete records in other tables, the code might need to be adapted.

Greetings,

Hilmar.


>hi all,
>this the code under sometimes work and delete ,somtimes work without delete,
>
>i need work and delete.
>any idea.
>
>CLOSE all
>SET TALK OFF
>SET ECHO OFF
>SET SAFETY OFF
>    thisform.text3.SetFocus
>     USE homecomm1 excl
>     zap
>  SELECT 0
>    USE newcomm66 EXCL
>    SET DELETED on
>    INDEX ON VAL(char2) TO hh
>
>     set order to "hh"
>     lnTotalCopied = 0
>     FOR i = 1 TO (thisform.text3.Value)  && assume 20 values for flag
>     lnTotalNeedingCopy = (thisform.text3.Value * i) - lnTotalCopied
>   SEEK i
>   COPY TO temp2 NEXT (lnTotalNeedingCopy) WHILE VAL(char2) = i
>   lnTotalCopied = lnTotalCopied + _Tally
>   SEEK i
>   DELETE NEXT (lnTotalNeedingCopy) WHILE VAL(char2) = i
>   SELECT homecomm1
>   APPEND FROM temp2
>   SELECT newcomm66
> NEXT
>   delete&&the proplem
> thisform.text3.SetFocus
>
>CLOSE ALL
>use homecomm1 excl
>BROWSE
>
>
>thanks.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform