Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can I Turn off Prefilling?
Message
De
22/03/1999 20:46:43
 
 
À
22/03/1999 18:46:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00200560
Message ID:
00200763
Vues:
10
>The APPEND BLANK sounds like the right idea, but does that
>require disabling the inherited code? I'm using wizbtns.vcx
>which was put there by the form wizard, and it does some
>things right. All the code in these buttons is defaulted
>from some magical parent class. Would a hard-coded append
>override it all?



Well, simple code can do, suppose there are two buttons "CmdAdd", "CmdDel"
* CmdAdd.Click()
#CAPADD "Add \<New"
#CAPDEL "\<Delete"
#CAPCOM "Comp\<leted"
#CAPCAN "Can\<cel"

IF THIS.CAPTION = CAPADD
* ADD NEW RECORD
THIS.CAPTION = CAPCOM
THISFORM.CMDDEL.CAPTION = CAPCAN

Select myTable  && Avoid Work Area
Append Blank
** If you've and reference Key_No, replace with right value!!
** i.e. REPLACE myKEY_NO with ...

Thisform.Refresh
ELSE
* COMPLETE
THIS.CAPTION = CAPADD
THISFORM.CMDDEL.CAPTION = CAPDEL

Select myTable
   IF TABLEUPDATE(.F.) > 0
      WAIT WINDOW "New Record Successful added!" NOWAIT
   ELSE
      MESSAGEBOX("Fail to Add New Record!", 16, _SCREEN.CAPTION)
      =TABLEREVERT(.F.)
      GO LAST
   ENDIF
THISFORM.REFRESH
ENDIF

* CmdDel.Click()
#CAPADD "Add \<New"
#CAPDEL "\<Delete"
#CAPCOM "Comp\<leted"
#CAPCAN "Can\<cel"

IF THIS.CAPTION = CAPDEL
* DELETE RECORD
THIS.CAPTION = CAPADD
THISFORM.CMDDEL.CAPTION = CAPDEL

SELECT myTable
DELETE
SKIP -1
THISFORM.REFRESH

ELSE
* CANCEL ADD
THIS.CAPTION = CAPADD
THISFORM.CMDDEL.CAPTION = CAPDEL

SELECT myTable
TABLEREVERT(.F.)
SKIP -1
THISFORM.REFRESH

ENDIF



Anyway, the above code is a simply sample, you can add your own style!

What's more, DON'T use Combox nor Listbox at your form if you're using VFP 5.0
without download SP3 fix from microsoft.
If you use VFP 6.0, no problem!

Because it will move to WRONG record when "Thisform.Refresh"

P.S. I haven't compile above code, it may contain errors.. >^.^<
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform