II've read your dialogue with JosP.
You should at least check that LOCATE has indeed found a record.
From the VFP8 Help on REPLACE:
The default scope for REPLACE is the current record (NEXT 1).
good luck
>Here is the code from my swap routine.
>
>nBay1, cLevel1, nBay2, cLevel2 are the parameters sent. This routine is designed to swap the contents of two bays on a side load beverage delivery vehicle.
>
>load_out_v is a view
>
>SELECT load_out_v
>LOCATE FOR load_out_v.delivery_date = route_status_vp.delivery_date ;
> AND load_out_v.route_id = route_status_vp.route_id ;
> AND load_out_v.load_number = route_status_vp.load_number ;
> AND load_out_v.bay_number = nBay1 ;
> AND load_out_v.bay_level = cLevel1
>cBay1_Side = load_out_v.side
>cBay1_Wide_Bay = load_out_v.wide_bay
>
>LOCATE FOR load_out_v.delivery_date = route_status_vp.delivery_date ;
> AND load_out_v.route_id = route_status_vp.route_id ;
> AND load_out_v.load_number = route_status_vp.load_number ;
> AND load_out_v.bay_number = nBay2 ;
> AND load_out_v.bay_level = cLevel2
>cBay2_Side = load_out_v.side
>cBay2_Wide_Bay = load_out_v.wide_bay
>
>* Perform the load_out_v swap by moving bay1 to -1, move bay2 to bay1 and set
>* side and wide parameters, move former bay1 (currently at -1) to bay2 and
>* set side and wide parameters
>
>REPLACE load_out_v.bay_number WITH -1 ;
> FOR load_out_v.delivery_date = route_status_vp.delivery_date ;
> AND load_out_v.route_id = route_status_vp.route_id ;
> AND load_out_v.load_number = route_status_vp.load_number ;
> AND load_out_v.bay_number = nBay1 ;
> AND load_out_v.bay_level = cLevel1 ;
> IN load_out_v
>SELECT load_out_v
>BROWSE
>
>WAIT WINDOW "replace " + STR(nBay2) + cLevel2 + " with " + STR(nBay1) + cLevel1
>REPLACE ALL load_out_v.bay_number WITH nBay1, ;
> load_out_v.bay_level WITH cLevel1, ;
> load_out_v.side WITH cBay1_Side, ;
> load_out_v.wide_bay WITH cBay1_Wide_Bay ;
> FOR load_out_v.delivery_date = route_status_vp.delivery_date ;
> AND load_out_v.route_id = route_status_vp.route_id ;
> AND load_out_v.load_number = route_status_vp.load_number ;
> AND load_out_v.bay_number = nBay2 ;
> AND load_out_v.bay_level = cLevel2 ;
> IN load_out_v
>SELECT load_out_v
>BROWSE
>
>WAIT WINDOW "replace -1 with " + STR(nBay2) + cLevel2
>REPLACE ALL load_out_v.bay_number WITH nBay2, ;
> load_out_v.bay_level WITH cLevel2, ;
> load_out_v.side WITH cBay2_Side, ;
> load_out_v.wide_bay WITH cBay2_Wide_Bay ;
> FOR load_out_v.delivery_date = route_status_vp.delivery_date ;
> AND load_out_v.route_id = route_status_vp.route_id ;
> AND load_out_v.load_number = route_status_vp.load_number ;
> AND load_out_v.bay_number = -1 ;
> IN load_out_v
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement