Re: Updating a field in Browse by Cindy
Cindy
Fri May 21 14:14:21 CDT 2004
In news: 8F1DC3D5-3DAB-4434-81FC-CC358770AEFC@microsoft.com,
Tony <tony.robins@failteireland.ie> wrote:
> our users want to update records in browse window but we need to
> automatically update a date field and a modby field when they change
> a record. How can this be done?
Hi Tony,
Check out the Valid clause of the Browse command. Here's some code I have
that's similar to what you want:
BROWSE NOWAIT TITLE "Univeristy Payroll Distribution" ;
NOAPPEND NOMENU IN WINDOW Brow1 ;
FIELDS BFR10 :W=.F., ;
Fund :P="@! NNN-NNNN" :V=LastUsed() AND FundValid(.T., [PyrlDist]), ;
OBJECT :V=LastUsed(), ;
Component :V=LastUsed(), ;
Percent :V=LastUsed(), ;
Cost=ROUND((PedPyrl.UnivCuRate+PedPyrl.AwdCuRate)*PedPyrl.FyHours* ;
Percent/100*PedPyrl.WorkSched/40, 2) :10 :W=.F., ;
Fte = ROUND(Percent/100*PedPyrl.WorkSched/40, 2) :5 :W=.F., ;
EndDate :W=.F., ;
UserID :W=.F., LastUpdt :W=.F. ;
COLOR RGB(0, 0, 128, 255, 255, 255) ;
FOR PyrlDist.EmpId = PedDemog.EmpId
LastUsed() looks like this:
*!* Assumes proper table is selected
*!* Called by valids in browses
FUNCTION LastUsed
REPLACE Userid WITH PedUsers.UserId, LastUpdt WITH DATE()
RETURN .T.
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy.winegarden@mvps.org www.cindywinegarden.com