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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace statement not working 2

Status
Not open for further replies.

RGoldthorpe

Technical User
Aug 10, 2001
83
GB
Can somebody help me please

why do my replace statements not work they are

APPEND BLANK in StoredLoads

replace StoredLoads.stl_sSeason with thisform.Season.value
replace StoredLoads.stl_sSite with thisform.Site.value
replace StoredLoads.stl_sStore with thisform.Store.value
replace StoredLoads.stl_sLOADid with thisform.LoadId.value
replace StoredLoads.stl_sVA with thisform.VANumber.value
replace StoredLoads.stl_sGrower with thisform.Grower.value
replace StoredLoads.stl_sWBId with thisform.WBNumber.value
replace StoredLoads.stl_sFieldId with thisform.FieldId.value
replace StoredLoads.stl_sPlotId with thisform.PlotId.value
replace StoredLoads.stl_fWeight with thisform.weight.value
replace StoredLoads.stl_fRemaining with thisform.weight.value
replace StoredLoads.stl_iBoxes with thisform.numboxes.value
replace StoredLoads.stl_bAccept with thisform.accepted.logicvalue
replace StoredLoads.stl_sPool with thisform.pool.value
replace StoredLoads.stl_HALStoreID with NULL
replace StoredLoads.stl_fRemainingboxes with thisform.numboxes.value
replace StoredLoads.stl_dDateOut with NULL
replace StoredLoads.stl_scomments with thisform.COMMENTS.Value
replace StoredLoads.stl_dDatein with thisform.Date.Value

=TABLEUPDATE(.T.,.T.,"storedloads")

It appends the blank record OK but then does not copy in the data from the form Unless the site selected is HIG 01

Any ideas much appreciated
 
HI
1. Just a little comment...
lcAlias = ALIAS()
SELECT StoredLoads
APPEND BLANK
replace stl_sSeason with thisform.Season.value, ;
stl_sSite with thisform.Site.value, ;
stl_sStore with thisform.Store.value, ;
stl_sLOADid with thisform.LoadId.value, ;
stl_sVA with thisform.VANumber.value, ;
stl_sGrower with thisform.Grower.value, ;
stl_sWBId with thisform.WBNumber.value, ;
stl_sFieldId with thisform.FieldId.value, ;
stl_sPlotId with thisform.PlotId.value, ;
stl_fWeight With thisform.weight.value, ;
stl_fRemaining with thisform.weight.valuem, ;
stl_iBoxes with thisform.numboxes.valuem,;
stl_bAccept with thisform.accepted.logicvalue,;
stl_sPool with thisform.pool.value,;
stl_HALStoreID with NULL,;
stl_fRemainingboxes with thisform.numboxes.value,;
stl_dDateOut with NULL,;
stl_scomments with thisform.COMMENTS.Value,;
stl_dDatein with thisform.Date.Value

=TABLEUPDATE(.t.,.t.)
SELECT (lcAlias)

The above code will be must faster.. rather than using many REPLACE commands.

2. Now regarding why it is not updating...
If you have the forms textbox etc objects... bound to the table.. this ill not update the above for obvious reason.. that when you append blank... record pointer gets to the appended blank record and all these objects get that value.
Is that the reason ?????
If that is the case... bindings shall be removed... but thibk.. when you navigate what is goint to happen..

The append has to be even before the data is accepted in those text boxes....

:)

ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
I've also had a similar problem and had to use some redundant coding to solve it... like this:

replace storedloads.stl_sSite with thisform.Site.value in storedloads

Steve
 
You will find this to be a FoxPro quirk, and you can prove it in the command window with a couple of tables

SELE Table2

APPE BLAN in Table 1
REPL Table1.Date WITH DATE()

SELE Table1
BROW

The quickest way to add a record is to use INSERT - SQL instead of APPE BLAN

Chris :)
 
Often it is the case that your currently selected alias is on EOF() (end of file),

If that is the case, your replacement in another alias will not work. Either slect the alias in which you wish to append/replace or make sure your currently selected alias is not on EOF().

HTH,

BTW why would you want to replace table fields with control values, if you could bound the controls to a field ?

Weedz (Wietze Veld)
My private project:Download the CrownBase source code !!
 
Hi
I agree with Chris..
"The quickest way to add a record is to use INSERT - SQL instead of APPE BLANK"

Instead of REPLACE commands...this can work..

***********************************************
lcAlias = ALIAS()
SELECT StoredLoads
SCATTER MEMVAR BLANK MEMO
m.stl_sSeason = thisform.Season.value
m.stl_sSite = thisform.Site.value
m.stl_sStore = thisform.Store.value
m.stl_sLOADid = thisform.LoadId.value
m.stl_sVA = thisform.VANumber.value
m.stl_sGrower = thisform.Grower.value
m.stl_sWBId = thisform.WBNumber.value
m.stl_sFieldId = thisform.FieldId.value
m.stl_sPlotId = thisform.PlotId.value
m.stl_fWeight = thisform.weight.value
m.stl_fRemaining = thisform.weight.valuem
m.stl_iBoxes = thisform.numboxes.valuem
m.stl_bAccept = thisform.accepted.logicvalue
m.stl_sPool = thisform.pool.value
m.stl_HALStoreID = NULL
m.stl_fRemainingboxes = thisform.numboxes.value
m.stl_dDateOut = NULL
m.stl_scomments = thisform.COMMENTS.Value
m.stl_dDatein = thisform.Date.Value
INSERT INTO StoredLoads FROM memvar
=TABLEUPDATE(.t.,.t.)
SELECT (lcAlias)
**************************************************
Rachel.. hope this sorts out your problem :)
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Hi ramani

wat is it used for below statements :
I never used before.

SCATTER MEMVAR BLANK MEMO
 
I haven't used scatter much either except for practice, but it's not difficult to understand from the explanation in the help files. VFP creates a set of blank variables having the name of all the fields in the table 'storedloads' with the field names preficed with an 'm'. With the MEMO keyword, this will include memo fields (though not general fields or pictures). Because the memory variables are blank, you can put what you want into them and then via the insert command [or via REPLACE if you're using a BLANK record or an existing one] create a new record having the memory variables.

The only thing I've have a question about is what to do with the MEMVARs at this point? I don't know if you should release them, blank them, or ignore them. The question being what happens if you try another SCATTER MEMVARS BLANK? Does it overwrite existing variables or create an error?

Dave Dardinger
 
Dave

In this example you could:-

RELE ALL LIKE stl_*

Does it overwrite existing variables or create an error?

It will overwrite existing variables

Chris :)



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top