Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Appending a new record
Message
 
 
À
18/08/2000 10:01:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00406633
Message ID:
00406780
Vues:
27
I can not tell what your problem really is. So I am going to walk through your code and intersperse comments.

>Help,
>
>I'm trying to append a table after I geather information from a screen form and befor posting. What I do is geather the information from the screen via text.values and replace the fields of one table with them. I do my calcs. in the replace meathord.
>
>My command button code is the following:
>
>set default to \efg

Why is the above code needed? If all directory paths are in your SET PATH statement in your MAIN.PRG, you do not need to worry about a DEFAULT path, etc.

>set talk off
>set deleted on

The 2 lines above should be placed in the LOAD method of your form baseclass and never manually included again. See VFP HELP on SET DATASESSION to see a complete list of all environment settings that are scoped to each data session.

>use pay in 0

The PAY table is not necessarily the currently selected workarea. So if PAY is the table being scanned below, you should have:

select pay

You will be better off performance-wise to create a parameterized view of the pay table with the filters INS_CO_NAM = ?cIns_Co_Nam and one for Group_Code = ?cGroup_Code. Put this view in the form's DataEnvironment and set the NoDataOnLoad property to TRUE. Name the view something like lv_PAY.

Then to retrieve the data for the view all you do is:


cIns_Co_Name = trim(thisform.cboInsCo.DisplayValue)
cGroup_Code = trim(thisform.txtGroupCode.Value)
requery("lv_Pay")
SCAN
instead of SCAN FOR ins_co_nam = " INSURANCE CO NAME" AND GROUP_CODE = "A01"

>REPLACE PAIDDATE WITH THISFORM.TEXT1.VALUE,;
>FROMDATE WITH THISFORM.TEXT2.VALUE,;
>TODATE WITH THISFORM.TEXT3.VALUE,;
>SERVFEE WITH 1.00
>
>REPLACE BALANCE WITH AMT_PRE - SERVFEE,;
>PERCENT WITH BALANCE*.1, DUECOMPANY WITH BALANCE - PERCENT, POSTED WITH "P"
>
>ENDSCAN

>SELECT * FROM TEST, PAY WHERE TEST.SS_NUMB = PAY.SSNUMBER AND PAY.INS_CO_NAM = "INS1" AND PAY.GROUP_CODE = "A01" AND AMT_PRE > 1;
>INTO CURSOR CuReport ORDER BY TEST.LAST_NAME

I would also make the above SQL into a parameterized view [e.g., lv_ReportView] with 3 filters -- TEST.SS_NUMB = ?cSSNUMBER and PAY.INS_CO_NAM = ?cIns_Co_Nam and PAY.GROUP_CODE = cGroup_Code

cSSNumber = trim(lv_Pay.SSUnmber)
cIns_Co_Name = trim(thisform.cboInsCo.DisplayValue)
cGroup_Code = trim(thisform.txtGroupCode.Value)
requery("lv_ReportView")


>IF _TALLY > 0

IMO, if not eof("CuReport") or, if you go with the view, if not eof("lv_ReportView"), is better than _tally. If you ever work with remote data, _tally will not work. It only works with queries on local VFP tables.

>REPORT FORM payment3B preview
>
>inResponse = MESSAGE("DO YOU WANT TO POST DATA ?",36,"INS CO NAME")
>
>iF InResponse = 6

Again, work with the view instead of the table. Then you do not need the FOR clause in the SCAN

>SELECT PAY
>SCAN FOR GROUP_CODE = "A01" AND INS_CO_NAM = "INS CO NAME"
>
>SCATTER MEMVAR MEMO
>INSERT INTO hist(table) from MEMVAR
>ENDSCAN
>
>MESSAGEBOX("DATA HAS BEEN POSTED")
>ENDIF
>USE IN PAY

No need to close the table or the view.

>ELSE
>MESSAGEBOX("NO RECORDS FOUND THAT MATCH YOUR REQUEST")
>ENDIF
>
>What I like to be able to do is, before posting my information to the history (hist) table, append a (one) record to misc. table from information that is also on the screen form thisform.text4.value to misc.field1, thisform.text5.value to misc.field2 and not upset the first part of my code.

I don't understand why there is a problem inserting a record into another table whenever you want.
Mark McCasland
Midlothian, TX USA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform