>I have a form with a Grid (using View, updateable, buffermode = 5)... before the grid appears, on the form it prompts the user to enter a value to retrieve records from the table (100,000+ records) then a grid appears (a view with anywhere between a couple records to a few hundred records)... in testing my view retrieved 248 records, I made a change to just one record... clicked save (=tableupdate(1,.T.,"TAcustView")), a message "Running query...." with a progress bar appeared, and it went into a loop
9 times then it finished. I tried again with a different value, changed one record, it looped
11 times. Another value, it retrieved just a few records, it looped once. That's really strange... why? I checked the modified records (as well as the appended records) and all appears OK... but I find it puzzling that =tableupdate would "requery" too many times....
>
>Here's the code:
>
>* after prompting user for a value, pass it to SQL View to retrieve records
>PROCEDURE txtTAID.LostFocus
>if empty(this.value)
>* if blank, ask user if wish to cancel
>if msg(1,'TA Rep#')
>thisform.cmdQuit.click()
>return
>else
>thisform.txtTAID.setfocus()
>endif
>endif
>select TAcustView
>mTAID = this.value
>requery()
>if reccount() = 0
>msg(12,'No Assigned CMRs for this TA')
>thisform.txtTAID.setfocus()
>Endif
>ENDPROC
>
>* save changes (relinquish CMR assignment(s) from one TA rep to another TA rep)
>PROCEDURE clsdtlbtns.cmdSave.Click
>local mRecNo
>select TAcustView
>go top
>do while not eof()
>if not empty(TAcustView.assumer) and TAcustView.actflag = .T.
>mRecNo = recno()
>scatter memvar
>m.taid = m.assumer
>m.effmo = thisform.txtEffMo.value
>m.effsysdt = datetime()
>m.assumer = space(6)
>m.user = gcUser
>insert into TAcustView from memvar
>go mRecNo
>repl endmo with m.effmo, endsysdt with datetime(), actflag with .F.
>endif
>skip
>enddo
>=tableupdate(1,.T.,"TAcustView")
>thisform.showdetails(.F.)
>ENDPROC
>* A litle rewrite, with a different approach:
PROCEDURE clsdtlbtns.cmdSave.Click
LOCAL cTempAlias,aFldStruct[1],oScatterObj,cAliasIn,tNewEMo,cOrder
cAliasIn = ALIAS()
cTempAlias = SYS(2015)
tNewEMo = thisform.txtEffMo.value
SELECT 0
cOrder = ORDER('TAcustView')
=AFIELDS(aFldStruc,'TAcustView')
CREATE CURSOR (cTempAlias) FROM ARRAY aFldStruc
SELECT TAcustView
SET ORDER TO 0
SCAN FOR actflag and ! EMPTY(assumer)
SCATTER NAME oScatterObj MEMO
WITH oScatterObj
.taid = .assumer
.assumer = ''
.effsysdt = DATETIME()
.effmo = tNewEmo
.user = gcUser
ENDWITH
SELECT (cTempAlias)
APPEND BLANK
GATHER NAME oScatterObj MEMO
SELECT TAcustView
repl endmo with tNewEMo, endsysdt with datetime(), actflag with .F.
ENDSCAN
APPEND FROM (DBF(cTempAlias))
USE IN (cTempAlias)
=tableupdate(1,.T.,"TAcustView")
SET ORDER TO &cOrder
LOCATE
thisform.showdetails(.F.)
IF ! EMPTY(cAliasIn)
SELECT (cAliasIn)
ELSE
SELECT 0
ENDIF
ENDPROC
>And in the SQL View:
>
>
SELECT Tacust.*, Cmr.cmrname;
> FROM crsdata!tacust LEFT OUTER JOIN crsdata!cmr ;
> ON Tacust.cmrno = Cmr.cmrno;
> WHERE Tacust.taid = ?mtaid;
> AND Tacust.actflag = .T.
> ORDER BY Tacust.cmrno, Tacust.effmo, Tacust.endmo
>>
>TIA