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

cant save data

Status
Not open for further replies.

jhed

Programmer
Apr 21, 2014
33
PH
Please help!!

i'm trying to save data but i cant, is their any problem on my syntax..

SELECT sample
thisform.text1.Value = str(YEAR(DATE()))+'-'+ left(faculty.firstn,1) + LEFT(faculty.middlen,1)+LEFT(faculty.lastn,1)
replace prop_num WITH thisform.text1.Value

i want to save data from text1.. i have table sample and a field prop_num which is set to character...

thank you in advanece
 
Are you receiving an error message?

Where is the table located? If it's in %PROGRAM FILES% you're probably running into UAC.

There's not enough information here to make a suggestion.
 
no error at all.. no replacement in the status bar of vfp..my table or i should say my program folder is in my computer drive c:. but my other module on the save command are all working,...i think their is something on my syntax that prevents it to save the data
 
Replace works on the current record. Are you at EOF(), perhaps?

Bye, Olaf.
 
my table is empty sir...i also tried different table but still wont work...tried also the tableupdate function but no luck..
 
****update***

i think i see the problem....i tried adding data through append command and notice that i can add data through the code i write but when the table is empty, i cant add....any suggestions
 
If your table is empty you are at both BOF() and EOF(), Replace can't add a record, it's a command to update existing data, comparing to sql UPDATE. And APPEND won't error, if you use it on no record, it simply does nothing. Even if your table wouldn't be empty, after an APPEND you are at EOF.

If you want to insert data, use INSERT, or APPEND BLANK before REPLACE, but INSERT is preferred, as it does add a record with the wanted value in one go.

Bye, Olaf.
 
Code:
SELECT sample
 thisform.text1.Value = str(YEAR(DATE()))+'-'+ left(faculty.firstn,1) + LEFT(faculty.middlen,1)+LEFT(faculty.lastn,1)
 if eof() .or. bof()
   append blank
 endif
 replace prop_num WITH thisform.text1.Value

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Code:
SELECT sample
 thisform.text1.Value = str(YEAR(DATE()))+'-'+ left(faculty.firstn,1) + LEFT(faculty.middlen,1)+LEFT(faculty.lastn,1)
 if eof() .or. bof()
   append blank
 endif
 replace prop_num WITH thisform.text1.Value

I would leave out the if eof() .or. bof() test. In other words, do this:

Code:
SELECT sample
 thisform.text1.Value = str(YEAR(DATE()))+'-'+ left(faculty.firstn,1) + LEFT(faculty.middlen,1)+LEFT(faculty.lastn,1)
 append blank
 replace prop_num WITH thisform.text1.Value

That way, you'll always save the data in a new record, rather than overwriting the existing data.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well, I still would suggest INSERT, for adding records:

Code:
INSERT INTO sample (prop_num) Values (thisform.text1.Value )

Question also is, why to set a control value and insert that into the table, you courl use dataa binding, the text1.controlsource = prop_num, then setting the value is like a replace and to add a new record you'd then use APPEND BLANK.

So either use INSERT to add a record or the form with controls bound to fields and APPEND BLANK to let the form controls bind to a new, blank record.

APPEND BLANK has the disadvantage, that you trigger the INSERT trigger of the table, add blank values to indexes, then change values via controls or REPLACE and update indexes. If it is all about creating new data without a form, INSERT is the cleaner way to do it.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top