Steve-vfp9user
Programmer
Hello all,
The following code is used to store a product number/code from a table PRODLIST then search for that code in customer orders that have been archived (ARELATEPRODS) or are current (RELATEPRODS). The purpose of this is to find the last date the product was sold. As I have inherited this, it would have been more efficient st the time of sale, if the actual product was updated back to the PRODLIST table but this isn't the case.
Here's the code:
Is there a more efficient way to do this?
Thank you
Steve Williams
VFP9, SP2, Windows 10
The following code is used to store a product number/code from a table PRODLIST then search for that code in customer orders that have been archived (ARELATEPRODS) or are current (RELATEPRODS). The purpose of this is to find the last date the product was sold. As I have inherited this, it would have been more efficient st the time of sale, if the actual product was updated back to the PRODLIST table but this isn't the case.
Here's the code:
Code:
USE PRODLIST SHARED
GO TOP
DO WHILE NOT EOF()
STORE CTOD(" / / ") TO mlastsold
mprodlistrecno=RECNO()
GO mprodlistrecno
mprodnumb=0
mprodnumb=PRODNUMB
USE ARELATEPRODS SHARED && Archived Records
GO TOP
SCAN
IF PRODNUMB=mprodnumb
IF INVDATE>mlastsold
STORE INVDATE TO mlastsold
ENDIF
ENDIF
ENDSCAN
USE RELATEPRODS SHARED && Archived Records
GO TOP
SCAN
IF PRODNUMB=mprodnumb
IF INVDATE>mlastsold
STORE INVDATE TO mlastsold
ENDIF
ENDIF
ENDSCAN
* Replace the LASTSOLD field with the date
USE PRODLIST SHARED
GO mprodlistrecno
REPLACE LASTSOLD WITH mlastsold
SKIP
IF EOF()
EXIT
ENDIF
ENDDO
Is there a more efficient way to do this?
Thank you
Steve Williams
VFP9, SP2, Windows 10