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

record updates

Status
Not open for further replies.

foxnet

Programmer
Mar 24, 2005
21
US
I have some logic in a push button to save a record with a sequential number, which is stored in a control table. The logic only works once unless I close the form and re-enter it again. Does anybody know what could be causing the problem. I have added the code to obtain and store the sequentail number below. Thanks for any help


select * from sysfile into cursor csr_sys
sidnum = csr_sys.account + 1
replace account with sidnum in sysfile
 
Is there more than one record in csr_sys?
If so, at the end of your SELECT * ... command, the record pointer may not be positioned on the proper record. In fact even with a single record, it may be positioned on EOF(), which is really no record at all.
You should try using SEEK(), INDEXSEEK(), or even LOCATE. You can then lock the record and make sure you are replacing it with the proper incremental value.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Thanks for the help guys,

I have used debugger and every times it goes through the the "select * from sysfile into cursor csr_sys", it pulls the same value. It appears that the replace command never enters the new number into the table until the form closes. It is currently happening on version 5.0, and the select can only pull one record, since that is all that exist in the sysfile table. I have got it working by removing the table from the data environment and replacing the block of code with

use ../data/sysfile in 0
select * from sysfile into cursor csr_sys
sidnum = csr_sys.account + 1
replace sysfile.account with sidnum in sysfile
if used("sysfile")
use in sysfile
endif

I still have no idea on why I need to close the table every time.
 
I'll bet the table was buffered (because you had it in the DE), so the new value wasn't being saved out until you closed the form (because you had no TableUpdate()). SELECT pulls from the disk, not from the buffer.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top