Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Access the record afternew
Message
 
 
À
25/08/2003 11:18:05
Information générale
Forum:
Visual FoxPro
Catégorie:
CodeMine
Divers
Thread ID:
00822103
Message ID:
00823176
Vues:
27
Hi John,

>I'm attempting to add a childform to an existing form by using afternew or afternew2 (I have tried both). I want to setup the new record prior to calling the childform. It appears that I'm not changing the "new" and blank record but the I'm changing the last record. I'm creating the new record with a call from the an actionbuttonNew. I'm in the afternew routine and check the workarea to insure the right table. I'v also tried just using "replaces" in case the datamanager does something. So what is the correct way to call the child form and insure the it is using the new record?

IF m.cWorkarea = 'Enroll'
THISFORM.cmdatamanager.REPLACE('enroll','clientid',esclient.clientid)
THISFORM.cmdatamanager.REPLACE('enroll','enroll_dte',DATE())
THISFORM.editmode()
THISFORM.openchild('enroll_class.scx')
ENDIF
>

I am assuming you are opening a ChildForm that is also dealing with a child table.

Make sure that the cWorkArea of the actionbuttonNew is set to your Child table before calling it - or you will not be adding a new record when that button is called or pressed.

Perhaps this will fix the problem.

If the above doesn't fix the problem... you might want to call the ChildForm a little differently just for debugging purposes. Do this, drop a CommandButton on the Parent Form and in the click enter:
THISFORM.OpenChild('enroll_class.scx')
Then, drop a cmTools.CmdToolsActionButtonNew onto the Child Form, and sets its cWorkArea to the child table.

In the cmDataManager.AfterNew2() (found on the Parent form - not the Child form) enter:
IF m.cWorkarea = 'Enroll'
   REPLACE clientid with esclient.clientid
   REPLACE enroll_dte WITH DATE()
ENDIF
See if this is now working properly. If it is, I would think you might be able to better trace what is not correct in your code. Or, you might wish to test for an empty child table when opening the Child Form - and have the Child Form call its New button to add a new record (which would fire the AfterNew2() and populate the default fields).

I am sure you are probably aware of this, but in CodeMine 7/8 the proper place to set these defaults is really in a business rule CDE AfterNew(), AFterNew2(), etc. I seldom use the cmDataManager since all those items are found in the business rule.

HTH's

Mel Cummings
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform