i know im still a rookie, and im getting better. my code is not linking the 2
records in order to replace the correct data from file 2 (lopchk), it must be
simple cause i cant seem to get it.

Close Data
Create Cursor qdrotest (agency N (6), dpt N(2), employee N (6), lchkamt n
(10,2), ldate d, fretchk n(10,2), fdte d)
Select 0
Use F:\foxpro25\lopfi\dbases\fulopmas In 0 Shared Alias fulopmas
set order to key
SET FILTER TO fulopmas.qdro = "Q"
Select 0
Use F:\lopfi\dbases\lopchk In 0 Shared Alias lopchk
set order to empind
SELECT fulopmas
GO top
Scan
fkey=
PADL(fulopmas.agency,6,"0")+PADL(fulopmas.dpt,3,"0")+PADL(fulopmas.employee,6,"0")
Select lopchk
lkey =
(PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+PADL(lopchk.employee,6,"0")+STR(YEAR(lopchk.checkdte),4,0)+STR(MONTH(lopchk.checkdte),2,0))
If Seek (lkey)
if lopchk.checkamt > 0.00
select qdrotest
append blank
replace agency with fulopmas.agency,dpt with fulopmas.dpt,employee
with fulopmas.employee,fretchk with fulopmas.retchkamt,fdte with
fulopmas.dtlstchk
replace lchkamt with lopchk.checkamt, ldate with lopchk.checkdte
Endif
skip
Select fulopmas
endif
Endscan

Re: a scan/end scan question again. by Jack

Jack
Wed Aug 24 12:33:21 CDT 2005

On Wed, 24 Aug 2005 09:46:08 -0700, Tom
<Tom@discussions.microsoft.com> wrote:

>i know im still a rookie, and im getting better. my code is not linking the 2
>records in order to replace the correct data from file 2 (lopchk), it must be
>simple cause i cant seem to get it.
>
>Close Data
>Create Cursor qdrotest (agency N (6), dpt N(2), employee N (6), lchkamt n
>(10,2), ldate d, fretchk n(10,2), fdte d)
>Select 0
>Use F:\foxpro25\lopfi\dbases\fulopmas In 0 Shared Alias fulopmas
>set order to key
>SET FILTER TO fulopmas.qdro = "Q"
>Select 0
>Use F:\lopfi\dbases\lopchk In 0 Shared Alias lopchk
>set order to empind
>SELECT fulopmas
>GO top
>Scan
> fkey=
>PADL(fulopmas.agency,6,"0")+PADL(fulopmas.dpt,3,"0")+PADL(fulopmas.employee,6,"0")
> Select lopchk
> lkey =
>(PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+PADL(lopchk.employee,6,"0")+STR(YEAR(lopchk.checkdte),4,0)+STR(MONTH(lopchk.checkdte),2,0))
> If Seek (lkey)
> if lopchk.checkamt > 0.00
> select qdrotest
> append blank
> replace agency with fulopmas.agency,dpt with fulopmas.dpt,employee
>with fulopmas.employee,fretchk with fulopmas.retchkamt,fdte with
>fulopmas.dtlstchk
> replace lchkamt with lopchk.checkamt, ldate with lopchk.checkdte
> Endif
> skip
> Select fulopmas
> endif
>Endscan

You set 'fkey' from the current record in fulopmas, then as far as I
can see never use it.

You set 'lkey' from the current record in lopchk, then do a SEEK in
lopchk for 'lkey', which will always find the current record in
lopchk. Do you mean to use 'fkey' in the SEEK()?

What is the purpose of the 'skip' and the 'Select' near the bottom?
When the SKIP is executed, the current alias is either lopchk or
qdrotest, depending on whether or not the SEEK found a match. I don't
see any reason to do a SKIP.

The Select is executed only if the Seek found a match, but the current
work area will be lopchk if it didn't find a match. I don't see any
reason to do a Select.


Re: a scan/end scan question again. by Cindy

Cindy
Wed Aug 24 12:52:42 CDT 2005

Hi Tom,

See if this does what you want:


Close Data
Create Cursor qdrotest ;
(agency N (6), dpt N(2), employee N (6), ;
lchkamt N(10,2), ldate d, fretchk n(10,2), fdte d)
Use F:\foxpro25\lopfi\dbases\fulopmas In 0 ;
Shared Alias fulopmas Order Key
Use F:\lopfi\dbases\lopchk In 0 ;
Shared Alias lopchk Order EmpInd

Select fulopmas
Scan For fulopmas.qdro = "Q"
fkey= ;
PADL(fulopmas.agency,6,"0")+ ;
PADL(fulopmas.dpt,3,"0")+ ;
PADL(fulopmas.employee,6,"0")
lkey = ;
(PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+ ;
PADL(lopchk.employee,6,"0")+ ;
STR(YEAR(lopchk.checkdte),4,0)+ ;
STR(MONTH(lopchk.checkdte),2,0))

If Seek (lKey, "lopChk", "empind") ;
And lopChk.CheckAmt = 0
Insert Into qdrotest ;
(agency, dpt, employee, fretchk, ;
fdte, lchkamt, ldate) ;
Values ;
(fulopmas.agency, fulopmas.dpt, fulopmas.employee, ;
fulopmas.retchkamt, fulopmas.dtlstchk, ;
lopchk.checkamt, lopchk.checkdte)
EndIf
EndScan


--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden


"Tom" <Tom@discussions.microsoft.com> wrote in message
news:C8E047DA-3583-4B34-BAF9-929E6A022675@microsoft.com...
>i know im still a rookie, and im getting better. my code is not linking the
>2
> records in order to replace the correct data from file 2 (lopchk), it must
> be
> simple cause i cant seem to get it.
>
> Close Data
> Create Cursor qdrotest (agency N (6), dpt N(2), employee N (6), lchkamt n
> (10,2), ldate d, fretchk n(10,2), fdte d)
> Select 0
> Use F:\foxpro25\lopfi\dbases\fulopmas In 0 Shared Alias fulopmas
> set order to key
> SET FILTER TO fulopmas.qdro = "Q"
> Select 0
> Use F:\lopfi\dbases\lopchk In 0 Shared Alias lopchk
> set order to empind
> SELECT fulopmas
> GO top
> Scan
> fkey=
> PADL(fulopmas.agency,6,"0")+PADL(fulopmas.dpt,3,"0")+PADL(fulopmas.employee,6,"0")
> Select lopchk
> lkey =
> (PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+PADL(lopchk.employee,6,"0")+STR(YEAR(lopchk.checkdte),4,0)+STR(MONTH(lopchk.checkdte),2,0))
> If Seek (lkey)
> if lopchk.checkamt > 0.00
> select qdrotest
> append blank
> replace agency with fulopmas.agency,dpt with fulopmas.dpt,employee
> with fulopmas.employee,fretchk with fulopmas.retchkamt,fdte with
> fulopmas.dtlstchk
> replace lchkamt with lopchk.checkamt, ldate with lopchk.checkdte
> Endif
> skip
> Select fulopmas
> endif
> Endscan



Re: a scan/end scan question again. by Cindy

Cindy
Wed Aug 24 13:05:20 CDT 2005

Hi Tom,

See if this does what you want:


Close Data
Create Cursor qdrotest ;
(agency N (6), dpt N(2), employee N (6), ;
lchkamt N(10,2), ldate d, fretchk n(10,2), fdte d)
Use F:\foxpro25\lopfi\dbases\fulopmas In 0 ;
Shared Alias fulopmas Order Key
Use F:\lopfi\dbases\lopchk In 0 ;
Shared Alias lopchk Order EmpInd

Select fulopmas
Scan For fulopmas.qdro = "Q"
fkey= ;
PADL(fulopmas.agency,6,"0")+ ;
PADL(fulopmas.dpt,3,"0")+ ;
PADL(fulopmas.employee,6,"0")
lkey = ;
(PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+ ;
PADL(lopchk.employee,6,"0")+ ;
Left(DtoS(lopchk.checkdte), 6)
*-- Check out DtoS() in Help

If Seek (fKey, "lopChk", "empind") ;
And lopChk.CheckAmt > 0
Insert Into qdrotest ;
(agency, dpt, employee, fretchk, ;
fdte, lchkamt, ldate) ;
Values ;
(fulopmas.agency, fulopmas.dpt, fulopmas.employee, ;
fulopmas.retchkamt, fulopmas.dtlstchk, ;
lopchk.checkamt, lopchk.checkdte)
EndIf
EndScan


--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden


"Tom" <Tom@discussions.microsoft.com> wrote in message
news:C8E047DA-3583-4B34-BAF9-929E6A022675@microsoft.com...
>i know im still a rookie, and im getting better. my code is not linking the
>2
> records in order to replace the correct data from file 2 (lopchk), it must
> be
> simple cause i cant seem to get it.
>
> Close Data
> Create Cursor qdrotest (agency N (6), dpt N(2), employee N (6), lchkamt n
> (10,2), ldate d, fretchk n(10,2), fdte d)
> Select 0
> Use F:\foxpro25\lopfi\dbases\fulopmas In 0 Shared Alias fulopmas
> set order to key
> SET FILTER TO fulopmas.qdro = "Q"
> Select 0
> Use F:\lopfi\dbases\lopchk In 0 Shared Alias lopchk
> set order to empind
> SELECT fulopmas
> GO top
> Scan
> fkey=
> PADL(fulopmas.agency,6,"0")+PADL(fulopmas.dpt,3,"0")+PADL(fulopmas.employee,6,"0")
> Select lopchk
> lkey =
> (PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+PADL(lopchk.employee,6,"0")+STR(YEAR(lopchk.checkdte),4,0)+STR(MONTH(lopchk.checkdte),2,0))
> If Seek (lkey)
> if lopchk.checkamt > 0.00
> select qdrotest
> append blank
> replace agency with fulopmas.agency,dpt with fulopmas.dpt,employee
> with fulopmas.employee,fretchk with fulopmas.retchkamt,fdte with
> fulopmas.dtlstchk
> replace lchkamt with lopchk.checkamt, ldate with lopchk.checkdte
> Endif
> skip
> Select fulopmas
> endif
> Endscan




Re: a scan/end scan question again. by Cindy

Cindy
Wed Aug 24 13:06:58 CDT 2005

Hi Tom,

(Sorry for previous messages. OE is being flaky.)

See if this does what you want:


Close Data
Create Cursor qdrotest ;
(agency N (6), dpt N(2), employee N (6), ;
lchkamt N(10,2), ldate d, fretchk n(10,2), fdte d)
Use F:\foxpro25\lopfi\dbases\fulopmas In 0 ;
Shared Alias fulopmas Order Key
Use F:\lopfi\dbases\lopchk In 0 ;
Shared Alias lopchk Order EmpInd

Select fulopmas
Scan For fulopmas.qdro = "Q"
fkey= ;
PADL(fulopmas.agency,6,"0")+ ;
PADL(fulopmas.dpt,3,"0")+ ;
PADL(fulopmas.employee,6,"0")
lkey = ;
(PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+ ;
PADL(lopchk.employee,6,"0")+ ;
Left(DtoS(lopchk.checkdte), 6)
*-- Check out DtoS() in Help

If Seek (fKey, "lopChk", "empind") ;
And lopChk.CheckAmt > 0
Insert Into qdrotest ;
(agency, dpt, employee, fretchk, ;
fdte, lchkamt, ldate) ;
Values ;
(fulopmas.agency, fulopmas.dpt, fulopmas.employee, ;
fulopmas.retchkamt, fulopmas.dtlstchk, ;
lopchk.checkamt, lopchk.checkdte)
EndIf
EndScan


--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden


"Tom" <Tom@discussions.microsoft.com> wrote in message
news:C8E047DA-3583-4B34-BAF9-929E6A022675@microsoft.com...
>i know im still a rookie, and im getting better. my code is not linking the
>2
> records in order to replace the correct data from file 2 (lopchk), it must
> be
> simple cause i cant seem to get it.
>
> Close Data
> Create Cursor qdrotest (agency N (6), dpt N(2), employee N (6), lchkamt n
> (10,2), ldate d, fretchk n(10,2), fdte d)
> Select 0
> Use F:\foxpro25\lopfi\dbases\fulopmas In 0 Shared Alias fulopmas
> set order to key
> SET FILTER TO fulopmas.qdro = "Q"
> Select 0
> Use F:\lopfi\dbases\lopchk In 0 Shared Alias lopchk
> set order to empind
> SELECT fulopmas
> GO top
> Scan
> fkey=
> PADL(fulopmas.agency,6,"0")+PADL(fulopmas.dpt,3,"0")+PADL(fulopmas.employee,6,"0")
> Select lopchk
> lkey =
> (PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+PADL(lopchk.employee,6,"0")+STR(YEAR(lopchk.checkdte),4,0)+STR(MONTH(lopchk.checkdte),2,0))
> If Seek (lkey)
> if lopchk.checkamt > 0.00
> select qdrotest
> append blank
> replace agency with fulopmas.agency,dpt with fulopmas.dpt,employee
> with fulopmas.employee,fretchk with fulopmas.retchkamt,fdte with
> fulopmas.dtlstchk
> replace lchkamt with lopchk.checkamt, ldate with lopchk.checkdte
> Endif
> skip
> Select fulopmas
> endif
> Endscan





Re: a scan/end scan question again. by Tom

Tom
Wed Aug 24 13:24:09 CDT 2005

Cindy, i got your first post and tweaked it like your last before you posted,
its worked great.

i cannot thank you enough for your help. do you know of a Good reference
book i could get to give me a highly detailed reference to VFP?

i like this forum, but feel stupid asking basic questions all the time when
i feel i need someone to walk me through it, rather than give the answer.


"Cindy Winegarden" wrote:

> Hi Tom,
>
> (Sorry for previous messages. OE is being flaky.)
>
> See if this does what you want:
>
>
> Close Data
> Create Cursor qdrotest ;
> (agency N (6), dpt N(2), employee N (6), ;
> lchkamt N(10,2), ldate d, fretchk n(10,2), fdte d)
> Use F:\foxpro25\lopfi\dbases\fulopmas In 0 ;
> Shared Alias fulopmas Order Key
> Use F:\lopfi\dbases\lopchk In 0 ;
> Shared Alias lopchk Order EmpInd
>
> Select fulopmas
> Scan For fulopmas.qdro = "Q"
> fkey= ;
> PADL(fulopmas.agency,6,"0")+ ;
> PADL(fulopmas.dpt,3,"0")+ ;
> PADL(fulopmas.employee,6,"0")
> lkey = ;
> (PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+ ;
> PADL(lopchk.employee,6,"0")+ ;
> Left(DtoS(lopchk.checkdte), 6)
> *-- Check out DtoS() in Help
>
> If Seek (fKey, "lopChk", "empind") ;
> And lopChk.CheckAmt > 0
> Insert Into qdrotest ;
> (agency, dpt, employee, fretchk, ;
> fdte, lchkamt, ldate) ;
> Values ;
> (fulopmas.agency, fulopmas.dpt, fulopmas.employee, ;
> fulopmas.retchkamt, fulopmas.dtlstchk, ;
> lopchk.checkamt, lopchk.checkdte)
> EndIf
> EndScan
>
>
> --
> Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
> cindy_winegarden@msn.com www.cindywinegarden.com
> Blog: http://spaces.msn.com/members/cindywinegarden
>
>
> "Tom" <Tom@discussions.microsoft.com> wrote in message
> news:C8E047DA-3583-4B34-BAF9-929E6A022675@microsoft.com...
> >i know im still a rookie, and im getting better. my code is not linking the
> >2
> > records in order to replace the correct data from file 2 (lopchk), it must
> > be
> > simple cause i cant seem to get it.
> >
> > Close Data
> > Create Cursor qdrotest (agency N (6), dpt N(2), employee N (6), lchkamt n
> > (10,2), ldate d, fretchk n(10,2), fdte d)
> > Select 0
> > Use F:\foxpro25\lopfi\dbases\fulopmas In 0 Shared Alias fulopmas
> > set order to key
> > SET FILTER TO fulopmas.qdro = "Q"
> > Select 0
> > Use F:\lopfi\dbases\lopchk In 0 Shared Alias lopchk
> > set order to empind
> > SELECT fulopmas
> > GO top
> > Scan
> > fkey=
> > PADL(fulopmas.agency,6,"0")+PADL(fulopmas.dpt,3,"0")+PADL(fulopmas.employee,6,"0")
> > Select lopchk
> > lkey =
> > (PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+PADL(lopchk.employee,6,"0")+STR(YEAR(lopchk.checkdte),4,0)+STR(MONTH(lopchk.checkdte),2,0))
> > If Seek (lkey)
> > if lopchk.checkamt > 0.00
> > select qdrotest
> > append blank
> > replace agency with fulopmas.agency,dpt with fulopmas.dpt,employee
> > with fulopmas.employee,fretchk with fulopmas.retchkamt,fdte with
> > fulopmas.dtlstchk
> > replace lchkamt with lopchk.checkamt, ldate with lopchk.checkdte
> > Endif
> > skip
> > Select fulopmas
> > endif
> > Endscan
>
>
>
>
>

Re: a scan/end scan question again. by Dan

Dan
Wed Aug 24 13:43:40 CDT 2005

The best reference to VFP is the Hacker's Guide, which hasn't been updated
since VFP7. It's available from www.hentzenwerke.com, as are a number of
other high-quality books about VFP.

You can fill in the bits added to VFP from the "What's new in..." titles for
VFP8 and VFP9, again from Hentzenwerke.

Dan

Tom wrote:
> Cindy, i got your first post and tweaked it like your last before you
> posted, its worked great.
>
> i cannot thank you enough for your help. do you know of a Good
> reference book i could get to give me a highly detailed reference to
> VFP?
>
> i like this forum, but feel stupid asking basic questions all the
> time when i feel i need someone to walk me through it, rather than
> give the answer.
>
>
> "Cindy Winegarden" wrote:
>
>> Hi Tom,
>>
>> (Sorry for previous messages. OE is being flaky.)
>>
>> See if this does what you want:
>>
>>
>> Close Data
>> Create Cursor qdrotest ;
>> (agency N (6), dpt N(2), employee N (6), ;
>> lchkamt N(10,2), ldate d, fretchk n(10,2), fdte d)
>> Use F:\foxpro25\lopfi\dbases\fulopmas In 0 ;
>> Shared Alias fulopmas Order Key
>> Use F:\lopfi\dbases\lopchk In 0 ;
>> Shared Alias lopchk Order EmpInd
>>
>> Select fulopmas
>> Scan For fulopmas.qdro = "Q"
>> fkey= ;
>> PADL(fulopmas.agency,6,"0")+ ;
>> PADL(fulopmas.dpt,3,"0")+ ;
>> PADL(fulopmas.employee,6,"0")
>> lkey = ;
>> (PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+ ;
>> PADL(lopchk.employee,6,"0")+ ;
>> Left(DtoS(lopchk.checkdte), 6)
>> *-- Check out DtoS() in Help
>>
>> If Seek (fKey, "lopChk", "empind") ;
>> And lopChk.CheckAmt > 0
>> Insert Into qdrotest ;
>> (agency, dpt, employee, fretchk, ;
>> fdte, lchkamt, ldate) ;
>> Values ;
>> (fulopmas.agency, fulopmas.dpt, fulopmas.employee, ;
>> fulopmas.retchkamt, fulopmas.dtlstchk, ;
>> lopchk.checkamt, lopchk.checkdte)
>> EndIf
>> EndScan
>>
>>
>> --
>> Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
>> cindy_winegarden@msn.com www.cindywinegarden.com
>> Blog: http://spaces.msn.com/members/cindywinegarden
>>
>>
>> "Tom" <Tom@discussions.microsoft.com> wrote in message
>> news:C8E047DA-3583-4B34-BAF9-929E6A022675@microsoft.com...
>>> i know im still a rookie, and im getting better. my code is not
>>> linking the 2
>>> records in order to replace the correct data from file 2 (lopchk),
>>> it must be
>>> simple cause i cant seem to get it.
>>>
>>> Close Data
>>> Create Cursor qdrotest (agency N (6), dpt N(2), employee N (6),
>>> lchkamt n (10,2), ldate d, fretchk n(10,2), fdte d)
>>> Select 0
>>> Use F:\foxpro25\lopfi\dbases\fulopmas In 0 Shared Alias fulopmas
>>> set order to key
>>> SET FILTER TO fulopmas.qdro = "Q"
>>> Select 0
>>> Use F:\lopfi\dbases\lopchk In 0 Shared Alias lopchk
>>> set order to empind
>>> SELECT fulopmas
>>> GO top
>>> Scan
>>> fkey=
>>>
PADL(fulopmas.agency,6,"0")+PADL(fulopmas.dpt,3,"0")+PADL(fulopmas.employee,
6,"0")
>>> Select lopchk
>>> lkey =
>>>
(PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+PADL(lopchk.employee,6,"0"
)+STR(YEAR(lopchk.checkdte),4,0)+STR(MONTH(lopchk.checkdte),2,0))
>>> If Seek (lkey)
>>> if lopchk.checkamt > 0.00
>>> select qdrotest
>>> append blank
>>> replace agency with fulopmas.agency,dpt with
>>> fulopmas.dpt,employee with fulopmas.employee,fretchk with
>>> fulopmas.retchkamt,fdte with fulopmas.dtlstchk
>>> replace lchkamt with lopchk.checkamt, ldate with
>>> lopchk.checkdte Endif
>>> skip
>>> Select fulopmas
>>> endif
>>> Endscan



Re: a scan/end scan question again. by Tom

Tom
Wed Aug 24 13:47:08 CDT 2005

Cindy, that works fine with one exception...

it puts 41 records into qdrotest. the problem in Fulopmas has 104.

if i open the tabel and count for qdro= "Q" i get 104 recs.

is there a reason its not picking up those 63 recs?



Re: a scan/end scan question again. by Jack

Jack
Wed Aug 24 15:05:10 CDT 2005

Cindy,

What am I missing here?

'fkey' is set but never used.

'lkey' is set from the current record in lopchk, and is used to Seek
in lopchk. Why doesn't the seek always work?

On Wed, 24 Aug 2005 13:52:42 -0400, "Cindy Winegarden"
<cindy_winegarden@msn.com> wrote:

>Hi Tom,
>
>See if this does what you want:
>
>
>Close Data
>Create Cursor qdrotest ;
> (agency N (6), dpt N(2), employee N (6), ;
> lchkamt N(10,2), ldate d, fretchk n(10,2), fdte d)
>Use F:\foxpro25\lopfi\dbases\fulopmas In 0 ;
> Shared Alias fulopmas Order Key
>Use F:\lopfi\dbases\lopchk In 0 ;
> Shared Alias lopchk Order EmpInd
>
>Select fulopmas
>Scan For fulopmas.qdro = "Q"
> fkey= ;
> PADL(fulopmas.agency,6,"0")+ ;
> PADL(fulopmas.dpt,3,"0")+ ;
> PADL(fulopmas.employee,6,"0")
> lkey = ;
> (PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+ ;
> PADL(lopchk.employee,6,"0")+ ;
> STR(YEAR(lopchk.checkdte),4,0)+ ;
> STR(MONTH(lopchk.checkdte),2,0))
>
> If Seek (lKey, "lopChk", "empind") ;
> And lopChk.CheckAmt = 0
> Insert Into qdrotest ;
> (agency, dpt, employee, fretchk, ;
> fdte, lchkamt, ldate) ;
> Values ;
> (fulopmas.agency, fulopmas.dpt, fulopmas.employee, ;
> fulopmas.retchkamt, fulopmas.dtlstchk, ;
> lopchk.checkamt, lopchk.checkdte)
> EndIf
>EndScan


SV: a scan/end scan question again. by Anders

Anders
Wed Aug 24 15:11:14 CDT 2005

Hi Tom
Try some SQL

Create Cursor qdrotest (agency N (6), dpt N(2), employee N (6),;
lchkamt n(10,2), ldate d, fretchk n(10,2), fdte d)

INSERT INTO Qdrotest ;
(agency,dpt,employee,lchkamt,ldate,fretchk,fdte) ;
SELECT F1.agency, .F1.dpt, F1.employee, F1.checkkamt, ;
F1.checkdte, F1.retchkamt, F1.dtlstchk ;
FROM Fulopmas AS F1 JOIN Lopchk AS L1 ;
ON F1.agency=L1.agency ;
AND F1.dpt=L1.dpt ;
AND F1.employee=L1.employee ;
AND YEAR(F1.checkdte)= YEAR(L1.checkdte) ;
AND MONTH(F1.checkdte)=MONTH(L1.checkdte) ;
WHERE F1.qdro='Q' AND L1.chckamt>0

A suggestion to a newbie: use the fullest and most understandable table and
column names possible. Will you remember two years from now what 'fretchk'
and 'ldate' or 'lchkamt' or 'qdro' all meant.
And where check became chk or and a date column is 'date' or 'dte' or 'dt..
something?
Tables in a VFP database have no restrictions on the length of column
names.
-Anders


Den 05-08-24 18.46, i artikeln
C8E047DA-3583-4B34-BAF9-929E6A022675@microsoft.com, skrev "Tom"
<Tom@discussions.microsoft.com>:

> i know im still a rookie, and im getting better. my code is not linking the 2
> records in order to replace the correct data from file 2 (lopchk), it must be
> simple cause i cant seem to get it.
>
> Close Data
> Create Cursor qdrotest (agency N (6), dpt N(2), employee N (6), lchkamt n
> (10,2), ldate d, fretchk n(10,2), fdte d)
> Select 0
> Use F:\foxpro25\lopfi\dbases\fulopmas In 0 Shared Alias fulopmas
> set order to key
> SET FILTER TO fulopmas.qdro = "Q"
> Select 0
> Use F:\lopfi\dbases\lopchk In 0 Shared Alias lopchk
> set order to empind
> SELECT fulopmas
> GO top
> Scan
> fkey=
> PADL(fulopmas.agency,6,"0")+PADL(fulopmas.dpt,3,"0")+PADL(fulopmas.employee,6,
> "0")
> Select lopchk
> lkey =
> (PADL(lopchk.agency,6,"0")+PADL(lopchk.dpt,3,"0")+PADL(lopchk.employee,6,"0")+
> STR(YEAR(lopchk.checkdte),4,0)+STR(MONTH(lopchk.checkdte),2,0))
> If Seek (lkey)
> if lopchk.checkamt > 0.00
> select qdrotest
> append blank
> replace agency with fulopmas.agency,dpt with fulopmas.dpt,employee
> with fulopmas.employee,fretchk with fulopmas.retchkamt,fdte with
> fulopmas.dtlstchk
> replace lchkamt with lopchk.checkamt, ldate with lopchk.checkdte
> Endif
> skip
> Select fulopmas
> endif
> Endscan


Re: a scan/end scan question again. by Cindy

Cindy
Wed Aug 24 14:11:57 CDT 2005

Hi Tom,

You are only inserting a record when you've found a record in lopChk and
loch.CheckAmt = 0. Does that change anything?


--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden


"Tom" <Tom@discussions.microsoft.com> wrote in message
news:A88043C2-2F01-486A-A410-97A65C76D50D@microsoft.com...
> Cindy, that works fine with one exception...
>
> it puts 41 records into qdrotest. the problem in Fulopmas has 104.
>
> if i open the tabel and count for qdro= "Q" i get 104 recs.
>
> is there a reason its not picking up those 63 recs?
>
>



Re: a scan/end scan question again. by Cindy

Cindy
Wed Aug 24 14:14:57 CDT 2005

Hi Tom,

There's a big difference between a "stupid" person and a person who's just
uninformed and needs to learn. We all, including me, started from knowing
zero at some point in our lives.

I've learned a lot from reading these groups over the years; also,
GoogleGroups (groups.google.com, the archives of these newsgroups) is a
great resource.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden


"Tom" <Tom@discussions.microsoft.com> wrote in message
news:18DEA2AF-8E8B-462B-BF96-1BC9033D3877@microsoft.com...
> Cindy, i got your first post and tweaked it like your last before you
> posted,
> its worked great.
>
> i cannot thank you enough for your help. do you know of a Good reference
> book i could get to give me a highly detailed reference to VFP?
>
> i like this forum, but feel stupid asking basic questions all the time
> when
> i feel i need someone to walk me through it, rather than give the answer.



Re: a scan/end scan question again. by Cindy

Cindy
Wed Aug 24 17:57:47 CDT 2005

What you're missing is my later post where I corrected the code to seek fkey
instead of lkey. I tried to cancel the above message but I guess it didn't
work.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden


"Jack Jackson" <jacknospam@pebbleridge.com> wrote in message
news:0nkpg1l90jvhq36p54ktfh8qlgq7ip15k0@4ax.com...
> Cindy,
>
> What am I missing here?
>
> 'fkey' is set but never used.
>
> 'lkey' is set from the current record in lopchk, and is used to Seek
> in lopchk. Why doesn't the seek always work?



Re: SV: a scan/end scan question again. by man-wai

man-wai
Thu Aug 25 06:51:13 CDT 2005

> A suggestion to a newbie: use the fullest and most understandable table and
> column names possible. Will you remember two years from now what 'fretchk'
> and 'ldate' or 'lchkamt' or 'qdro' all meant.

We are supposed to have something called data dictionary. :P
(is that an old idea in the advert of OOP and UML...)

--
.~. Might, Courage, Vision. http://www.linux-sxs.org
/ v \
/( _ )\ Linux 2.4.31
^ ^ 7:50pm up 1 day 23:27 load average: 0.01 0.04 0.10

Re: a scan/end scan question again. by Olaf

Olaf
Thu Aug 25 10:44:59 CDT 2005

> Select lopchk
> lkey = <some complex expression concatenating some fields of lopchk>
> If Seek (lkey)
> ...

I don't think this is what you want.

As you build lkey with values of fields of the active record of lopchk,
the Seek will find this key (assuming the index "empind" is defined with the same
expression) but will simply find the same record you already sit on, won't it?

If there are more records matching that expression you'd always
point to the first of these records after Seek().

I could imagine you wanted to do something like this instead (pseudocode):

select <parent table>
scan
fkey = <some index expression with fields of parent table found as foreign key in child table>
select <child table>
if seek(fkey)
scan rest while fkey = <some expression with fields of the child table>
<do something for all these child table records related to the active record of the parent table>
endscan
endif
endscan

Bye, Olaf.



Re: a scan/end scan question again. by Tom

Tom
Thu Aug 25 16:19:04 CDT 2005

Thank you all for your advice and patience as i know some of this is "easy"
for you.
i hope to continue to grow and develop skills i pick up on my own as wellas
from groupd like this.

Thanks again.

"Olaf Doschke" wrote:

> > Select lopchk
> > lkey = <some complex expression concatenating some fields of lopchk>
> > If Seek (lkey)
> > ...
>
> I don't think this is what you want.
>
> As you build lkey with values of fields of the active record of lopchk,
> the Seek will find this key (assuming the index "empind" is defined with the same
> expression) but will simply find the same record you already sit on, won't it?
>
> If there are more records matching that expression you'd always
> point to the first of these records after Seek().
>
> I could imagine you wanted to do something like this instead (pseudocode):
>
> select <parent table>
> scan
> fkey = <some index expression with fields of parent table found as foreign key in child table>
> select <child table>
> if seek(fkey)
> scan rest while fkey = <some expression with fields of the child table>
> <do something for all these child table records related to the active record of the parent table>
> endscan
> endif
> endscan
>
> Bye, Olaf.
>
>
>

SV: a scan/end scan question again. by Anders

Anders
Fri Aug 26 05:37:50 CDT 2005

Hi Tom,
Well I think this example and all the various suggestions that have been
posted go to show how complex and full of pitfalls a 'simple' piece of xbase
code with SCAN, REPLACE and SEEK can get to accomplish what basically a
standard filtered join query that SELECT .. FROM .. JOIN .. ON ... WHERE ..
will handle.
You're selecting some fields from a table while relating to another table on
some columns, and filtering on two columns, one in each table.
Now, was it the values in fkey or the values in lkey that should serve to
relate the tables?
-Anders


Den 05-08-25 23.19, i artikeln
1462A755-67EC-43FC-A2A9-AC38A968E2A6@microsoft.com, skrev "Tom"
<Tom@discussions.microsoft.com>:

> Thank you all for your advice and patience as i know some of this is "easy"
> for you.
> i hope to continue to grow and develop skills i pick up on my own as wellas
> from groupd like this.
>
> Thanks again.
>
> "Olaf Doschke" wrote:
>
>>> Select lopchk
>>> lkey = <some complex expression concatenating some fields of lopchk>
>>> If Seek (lkey)
>>> ...
>>
>> I don't think this is what you want.
>>
>> As you build lkey with values of fields of the active record of lopchk,
>> the Seek will find this key (assuming the index "empind" is defined with the
>> same
>> expression) but will simply find the same record you already sit on, won't
>> it?
>>
>> If there are more records matching that expression you'd always
>> point to the first of these records after Seek().
>>
>> I could imagine you wanted to do something like this instead (pseudocode):
>>
>> select <parent table>
>> scan
>> fkey = <some index expression with fields of parent table found as foreign
>> key in child table>
>> select <child table>
>> if seek(fkey)
>> scan rest while fkey = <some expression with fields of the child table>
>> <do something for all these child table records related to the
>> active record of the parent table>
>> endscan
>> endif
>> endscan
>>
>> Bye, Olaf.
>>
>>
>>


RE: SV: a scan/end scan question again. by Tom

Tom
Fri Aug 26 08:59:02 CDT 2005

Anders, the Value in fkey were from the Parent table in this case, those were
also filtered down to only the records i needed, in this case
fulopmas.qdro="Q", the lkey is from the child table. i needed to match the
records from the parent with the above filter, to (lkey) in the child, then
using the index (empind) in the child find the earilest date in the file for
that matching parent record. and append to a new table so i can output it to
a format (xls) or something.

when at the command line, browse for fulopmas.qdro="Q" returns 104 records.

when the code runs, it returns 41. that is a point of confusion for me as
well, i have used filters and things before without these kind of errors.

"Anders" wrote:

> Hi Tom,
> Well I think this example and all the various suggestions that have been
> posted go to show how complex and full of pitfalls a 'simple' piece of xbase
> code with SCAN, REPLACE and SEEK can get to accomplish what basically a
> standard filtered join query that SELECT .. FROM .. JOIN .. ON ... WHERE ..
> will handle.
> You're selecting some fields from a table while relating to another table on
> some columns, and filtering on two columns, one in each table.
> Now, was it the values in fkey or the values in lkey that should serve to
> relate the tables?
> -Anders
>
>
> Den 05-08-25 23.19, i artikeln
> 1462A755-67EC-43FC-A2A9-AC38A968E2A6@microsoft.com, skrev "Tom"
> <Tom@discussions.microsoft.com>:
>
> > Thank you all for your advice and patience as i know some of this is "easy"
> > for you.
> > i hope to continue to grow and develop skills i pick up on my own as wellas
> > from groupd like this.
> >
> > Thanks again.
> >
> > "Olaf Doschke" wrote:
> >
> >>> Select lopchk
> >>> lkey = <some complex expression concatenating some fields of lopchk>
> >>> If Seek (lkey)
> >>> ...
> >>
> >> I don't think this is what you want.
> >>
> >> As you build lkey with values of fields of the active record of lopchk,
> >> the Seek will find this key (assuming the index "empind" is defined with the
> >> same
> >> expression) but will simply find the same record you already sit on, won't
> >> it?
> >>
> >> If there are more records matching that expression you'd always
> >> point to the first of these records after Seek().
> >>
> >> I could imagine you wanted to do something like this instead (pseudocode):
> >>
> >> select <parent table>
> >> scan
> >> fkey = <some index expression with fields of parent table found as foreign
> >> key in child table>
> >> select <child table>
> >> if seek(fkey)
> >> scan rest while fkey = <some expression with fields of the child table>
> >> <do something for all these child table records related to the
> >> active record of the parent table>
> >> endscan
> >> endif
> >> endscan
> >>
> >> Bye, Olaf.
> >>
> >>
> >>
>
>

SV: SV: a scan/end scan question again. by Anders

Anders
Sun Aug 28 08:53:16 CDT 2005

Hi Tom,
Here's an example of how to join two tables that are in a one-to-many
relationship over several columns and get only the one on the many side that
has the latest date.

CREATE CURSOR Table1 (col1 i, col2 i , col3 i)
INSERT INTO Table1 VALUES (1,1,1)
INSERT INTO Table1 VALUES (1,2,1)
INSERT INTO Table1 VALUES (1,2,3)
INSERT INTO Table1 VALUES (2,2,2)
INSERT INTO Table1 VALUES (2,2,3)

CREATE CURSOR Table2 (col4 i, col5 i, col6 i, date d)
INSERT INTO Table2 VALUES (2,2,3, DATE())
INSERT INTO Table2 VALUES (2,2,3, DATE()-4)
INSERT INTO Table2 VALUES (2,2,3, DATE()+4)
INSERT INTO Table2 VALUES (1,2,3, DATE()-1)
INSERT INTO Table2 VALUES (1,2,3, DATE()-7)
INSERT INTO Table2 VALUES (1,2,1, DATE())

SELECT T1.col1,T1.col2,T1.col3, T2.date ;
FROM Table1 AS T1 JOIN Table2 AS T2 ;
ON T1.col1=T2.col4 AND T1.col2=T2.col5 AND T1.col3=T2.col6;
WHERE T2.date = ;
(SELECT MAX(date) FROM Table2 T2 ;
WHERE T1.col1=T2.col4 AND T1.col2=T2.col5 AND T1.col3=T2.col6)

-Anders


Den 05-08-26 15.59, i artikeln
6EC9E411-6C04-4CE4-87CE-5FA0A5EAECC4@microsoft.com, skrev "Tom"
<Tom@discussions.microsoft.com>:

> Anders, the Value in fkey were from the Parent table in this case, those were
> also filtered down to only the records i needed, in this case
> fulopmas.qdro="Q", the lkey is from the child table. i needed to match the
> records from the parent with the above filter, to (lkey) in the child, then
> using the index (empind) in the child find the earilest date in the file for
> that matching parent record. and append to a new table so i can output it to
> a format (xls) or something.
>
> when at the command line, browse for fulopmas.qdro="Q" returns 104 records.
>
> when the code runs, it returns 41. that is a point of confusion for me as
> well, i have used filters and things before without these kind of errors.
>