Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacement issue in foxpro 1

Status
Not open for further replies.

Niki_S

Programmer
Jun 4, 2021
232
LK

I have a issue when replacing data into my cursor.
Code:
IF thisform.cboBatchType.DisplayValue= 'Pending GRN'
	SELECT ACPGRN 
			GO TOP 
			REPLACE ALL cGRN WITH 'Awaiting'
ELSE 
 
		IF ACPGRN.nPoQty>ACPGRN.nGrnQtyVal THEN 
			SELECT ACPGRN 
			GO TOP 
			REPLACE  cGRN WITH 'Awaiting'
    
		ELSE
			SELECT ACPGRN 
			GO TOP 
			REPLACE cGRN WITH 'Completed'
		ENDIF 

ENDIF

According to this I need to be my cursor as below.
Code:
nPoQty      nGrnQtyVal       cGRN 
123         758              Awaiting
45          20               Completed
56          36               Completed
865         11256            Awaiting

How can I get like this output according to the above logic?
Thank you
 
Code:
IF thisform.cboBatchType.DisplayValue= 'Pending GRN' && Display Value - Really???
   UPDATE ACPGRN SET cGRN = 'Awaiting'
ELSE 
   UPDATE ACPGRN SET cGRN = IIF(ACPGRN.nPoQty>ACPGRN.nGrnQtyVal, 'Awaiting', Completed')
ENDIF

Borislav Borissov
VFP9 SP2, SQL Server
 
You're using REPLACE ALL in the IF branch and REPLACE without ALL in the ELSE branch.

I can't tell if that's the problem, as you tell you don't want all cGRN to the same value.

Your desired result is for which case? What are you selecting? If you select 'Pending GRN' this code will set all cGRN to Awaiting.
If you pick something else than it depends on the further logic what happens, but you only change the first record in all the ELSE branch cases.

I don't think you want ALL in any case, but also not just change the first record. Add a FOR clause to specify the condition for records to REPLACE the cGRN field there and/or SEEK or LOCATE to the record you want to change.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top