Do while found--- what if not found? 
Author Message
 Do while found--- what if not found?

CASE lcField = "AMOUNT"
   SELECT empschde
   LOCATE FOR (empdetai.Empnum)= lcEmpnum
   DO WHILE FOUND ( )
    WAIT WINDOW "Update Info: "+lcupdate NOWAIT
    REPLACE empdetai.amount WITH lcupdate
    REPLACE 'empdetai.code' WITH lzcode
    CONTINUE
   ENDDO
 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



Sun, 15 Dec 2002 03:00:00 GMT  
 Do while found--- what if not found?
How bout...

Quote:
> CASE lcField = "AMOUNT"
>    SELECT empschde
>    LOCATE FOR (empdetai.Empnum)= lcEmpnum

    if !found()
        insert into empdetai ( EmpNum ) value ( lcEmpNum )
    else
Quote:
>    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



Sun, 15 Dec 2002 03:00:00 GMT  
 Do while found--- what if not found?
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?

Quote:
> 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



Tue, 17 Dec 2002 03:00:00 GMT  
 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



Tue, 17 Dec 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. FOUND VFP5.0 GRID BUG - Column not found error

2. Edit (Find/Find Again)

3. Using Find and Find Again

4. VFP6.0 Install myPgm Setup.LST not found

5. VFP3 - Menu not found after switching to another application

6. Variable is not found

7. Variable not found - FPW2.6 - HELP -

8. Procedure Not Found

9. Form object name not found Problem

10. Query not found in VFP 5 combo list

11. object not found - show method

12. Error 13 Alias is not found

 

 
Powered by phpBB® Forum Software