Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why vfp lost data after returned modal form

Status
Not open for further replies.

kosta

Programmer
Feb 9, 2001
186
CA
Hi All,
i've a invoice form ( private datasession - buffermode pessimistic - Dataenvironmet buffer mode=5 ) , there is textbox etc. control for parent table and for the detail has a grid.
i am inserting records to the child table via detailAdd form ( default data session , buffermode 1-pessimistic and there is o table on dataenvironment )
and for editing detail via detailEdit form such as detailAdd only different is controlsources is not empty .

i have some calculations for invoice footer . these calculations are on grid afterrowcolchange event . calculations and other codes works well only when i edited or added some records these footer fields of parent table not updating ( i have a methods on my form save,delete,add,edit etc ) when i use this syntax


tableupdate(2,.t.,thisform.lcfile1)
tableupdate(2,.t.,thisform.lcfile2)
but when i use


tableupdate(2,.t.,'invheader')
tableupdate(2,.t.,'invdetail')
updating is Ok but record pointer goes next record

here is my some main form keypress event codes and save,delete,etc codes ..

* form keypress event

Lparameters nKeyCode, nShiftAltCtrl

If Type("_Screen.ActiveForm.ActiveControl")=="O"
Local loActiveControl
m.loActiveControl = _Screen.ActiveForm.ActiveControl
If m.loActiveControl.BaseClass = "Grid"
If nKeyCode=13
Select stokhd
lnrec=Recno("stokhd")
lcfiskodu=Thisform.txtfiskodu.Value
lcislemno=Thisform.txtIslemNo.Value
lcislemtipi=Thisform.txtIslemTipi.Value
lcfistipi=Thisform.lbl_fiskodu.Caption
lcdepokodu=Thisform.txtdepokodu.Value
lctdepokodu=Thisform.txttdepokodu.Value
lcmyguid=stokhb.myguid

Do Form Form\stokedit With m.lcfiskodu,m.lnrec,m.lcislemno,;
m.lcislemtipi,m.lcfistipi,m.lcdepokodu,m.lctdepokodu,m.lcmyguid &&TO lnrec

Go m.lnrec In stokhd
Thisform.grid1.SetFocus

If! Lastkey()=27
Thisform.addmode =.T.
Thisform.editmode =.T.
Keyboard '{F3}' &&oToolbar.cmdsave.Click()
Else
Thisform.addmode =.F.
Thisform.editmode =.F.
Keyboard '{F5}' &&oToolbar.cmdundo.Click()
Endif
Endif
If nKeyCode=145 && ctrl+dnarrow
oToolbar.cmdrowcopy.Click
Endif
Endif
Endif

If Thisform.addmode=.F. Or Thisform.editmode=.F.
Do Case
Case nKeyCode=18 &&pgup
oToolbar.cmdPrior.Click
Case nKeyCode=3 &&pgdn
oToolbar.cmdNext.Click
Case nKeyCode=31 &&ctrl+pgup
oToolbar.cmdFirst.Click
Case nKeyCode=30 &&ctrl+pgdn
oToolbar.cmdLast.Click
Case nKeyCode=-1 &&f2
oToolbar.cmdNew.Click
Case nKeyCode=-3 &&f4
oToolbar.cmdEdit.Click
Case nKeyCode=-5 && f6
oToolbar.cmdDelete.Click
Case nKeyCode=-7&& f8
oToolbar.cmdFind.Click
Case nKeyCode=-8 && f9
oToolbar.cmdPrint.Click
Case nKeyCode=-9 && f10
oToolbar.cmdQuit.Click
Case nKeyCode=27 &&esc
Thisform.Release
Endcase
Endif

If Thisform.addmode=.T. Or Thisform.editmode=.T.
Do Case
Case nKeyCode=-2 &&f3
oToolbar.cmdSave.Click
Case nKeyCode=-4 && f5
oToolbar.cmdUndo.Click
Endcase
Endif

* grid afterrowcolchange event

Lparameters nColIndex
DoDefault(nColIndex)

Thisform.LockScreen =.T.

Local btutar,atutar,lnyerno
Local toplamtutar,lnkdv,lnaltkdv,lnaltgtoplam,lnyerno,lnyerbaslik,topisktut

If ! Eof()

lnyerno=Recno("stokhd")
lnyerbaslik=Recno("stokhb")


stokhtutar = stokhd.miktar * stokhd.fiyat &&tutar hesab?
This.coltutar.text1.Value=stokhtutar


isktut1 = (stokhd.tutar * stokhd.iskonto) / 100
isktut2 = ((stokhd.tutar - isktut1) * stokhd.iskonto2) / 100
isktut3 = ((stokhd.tutar - (isktut1+isktut2)) * stokhd.iskonto3) / 100

stokhisktutar = isktut1 + isktut2 + isktut3
This.colisktutar.text1.Value=stokhisktutar

top1=stokhd.tutar - stokhd.isktutar &>oplam
top2=(top1 * stokhd.kdv ) /100
top3=top1+top2
Replace stokhd.kdvtut With top2 In 'stokhd'
This.colgtoplam.text1.Value=top3


If Thisform.Txtislemtipi.Value='G'
Replace stokhd.girmik With stokhd.miktar In 'stokhd'
Replace stokhd.cikmik With 0 In 'stokhd'
Else
Replace stokhd.cikmik With stokhd.miktar In 'stokhd'
Replace stokhd.girmik With 0 In 'stokhd'
Endif


Sum stokhd.isktutar To topisktut For stokhb.myguid==stokhd.pmyguid
Sum stokhd.tutar To toplamtutar For stokhb.myguid==stokhd.pmyguid
Sum stokhd.kdvtut To lnaltkdv For stokhb.myguid==stokhd.pmyguid

lnalttoplam=(toplamtutar-topisktut)
lnaltgtoplam=(toplamtutar-topisktut) + lnaltkdv

Go m.lnyerno In 'stokhd'
Thisform.txtaltisktut.Value=topisktut
Thisform.txtalttutar.Value=toplamtutar
Thisform.txtaltkdv.Value=lnaltkdv
Thisform.txtalttoplam.Value=lnalttoplam
Thisform.txtaltgtoplam.Value=lnaltgtoplam

Thisform.dovhesapla()
Thisform.Refresh
Endif
Thisform.LockScreen =.F.

* method cmdSave

Tableupdate(2,.T.,lcfile1)
Tableupdate(2,.T.,lcfile2)
normally this code must be update , because when modal form ( detailedit ) is closed grid ARCE calculating and refreshing related parent tables fields on the form but :( not

when change to cmdsave codes like below

Tableupdate(2,.T.,'invheader')
Tableupdate(2,.T.,'invdetail')
updating is Ok but record pointer goes next record :(

i couldnt any reason , if you were me how would be the your codes or your invoice form designs ? what is the important things about this issue ?

any help or suggestion would very appreciated..

TIA

Soykan OEZCELIK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top