
Do while found--- what if not found?
Hey Jacqueline,
I'm guessing zip code and amount are both fields in EmpDetai and lzcode and
lcupdate are memory variables with the appropriate values. IF this is true
and you already have positioned the employee table to the right record (with
LOCATE or (preferably) SEEK), then we just need to change the INSERT command
for those parts.
insert into empdetai ( EmpNum, Zip, Amount ) ;
value ( lcEmpNum, lzcode, lcupdate )
As for empshde, is this a related "detail" table of some sort? If you need
to add a new record, a similar insert command should work...
insert into empshde ( EmpNum, SocSec ) value ( lcEmpNum, Employee.SS_Num )
If instead it's an existing record that just needs to be updated, a REPLACE
would work...
REPLACE empshde.SocSec WITH Employee.SS_Num.
Replace is a core command in VFP when you're working with tables, but beware
of one thing. IF you are doing a replace on a table that is not the current
work area AND the current work area's table is at the end of file, you will
get an error.
HTH,
John
Quote:
> ok this is WONDERFUL... except for one thing... if the empnum is not found
> we need to create a whole new record which you are doing when you insert
the
> empnum but in the same record I need to insert the code (lzcode) and the
> amount (lcupdate) and the empshde.socsec which is taken from
> employee.ss_num. HELP?
> > How bout...
> > > CASE lcField = "AMOUNT"
> > > SELECT empschde
> > > LOCATE FOR (empdetai.Empnum)= lcEmpnum
> > if !found()
> > insert into empdetai ( EmpNum ) value ( lcEmpNum )
> > else
> > > DO WHILE FOUND ( )
> > > WAIT WINDOW "Update Info: "+lcupdate NOWAIT
> > > REPLACE empdetai.amount WITH lcupdate
> > > REPLACE 'empdetai.code' WITH lzcode
> > > CONTINUE
> > > ENDDO
> > endif
> > > ENDCASE
> > > ok... now how can I add lines to say that if the empnum is NOT found
> then
> > > add a record to the empschde?
> > > Thanks for all of your help!
> > > jacqueline