Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Delete records in grid and compute total
Message
 
 
À
18/04/2007 11:06:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00947104
Message ID:
01217323
Vues:
30
>If I move to another record manually, the record disappears when I try to go back.
>
>Are you saying that moving the record poiner programmatically does not make the record disappear?
>
>If this is the case, you need to post the code that deleted the record.

That's the exact code from my colleague except that I added the first top check for EOF() after getting an error trying to delete the first record.

I'm using CA and table buffering. My colleague usually prefers row-level buffering.
LOCAL lnRecNo, ;
	llRetVal

llRetVal = .T.
IF MESSAGEBOX(DELETEREC_LOC, ;
		MB_ICONQUESTION + MB_YESNO, ;
		DELETEWARN_LOC) = IDNO
	RETURN .F.
ENDIF

*-- If adding a new record, just revert it
IF "3" $ GETFLDSTATE(-1) OR "4" $ GETFLDSTATE(-1)
	THISFORM.RESTORE()
	RETURN .T.
ENDIF

lnRecNo = RECNO()
DELETE

*-- When buffering is in use, you need to move off the record to
*-- actually delete it. This may not be successful if the
*-- delete trigger fails.

IF NOT EOF()
	SKIP
	IF EOF()
		SKIP -1
		IF !BOF()
			THISFORM.RefreshForm()
		ELSE
*-- Ask to add a new record if user just deleted last record
*-- in file
			IF (MESSAGEBOX(ADDNEWREC_LOC, ;
					MB_ICONQUESTION + MB_YESNO, ;
					TASTRADE_LOC)) = IDYES
				THISFORM.AddNew()
			ELSE
*-- If user does not wish to add a new record, no sense keeping
*-- the form around.
				THISFORM.RELEASE()
			ENDIF
		ENDIF
	ELSE
		IF lnRecNo = RECNO()
			llRetVal = .F.
		ELSE
			THISFORM.RefreshForm()
		ENDIF
	ENDIF
ELSE && EOF
  SKIP -1	
  THISFORM.RefreshForm()	
ENDIF

RETURN m.llRetVal
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform