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

edit button in vfp9

Status
Not open for further replies.

ivatanakoo

IS-IT--Management
Oct 9, 2014
23
PH


select item_tbl
replace pic with thisform.image.picture

but it replaces the picture of the first record
and nothing happens to the current record i want to edit.


actually, that form contains table and i can see where the pointer points into the record.
i think goto top is something to do with this,but when i remove it the record im trying to edit didnt update.
please help...
 
also tried this:
locate for field=thisform.item.value
if found()
replace pic
endif
but nothing works..
iam not using control source for my textbox...
is this the reason..?
 
In general, a REPLACE command will operate on the current record, that is, the one indicated by the record pointer. If you want it to operate on more than the current record, you must add a scope clause, such as ALL or FOR or REST.

You are right about GO TOP. That will move the record pointer to the first record (in index order).

In your second message, [tt]REPLACE Pic[/tt] won't do anything. You need to say [tt]REPLACE Pic WITH ....[/tt]

You say you are not using a control source for the textbox. That in itself is not a problem, provided the textbox has a value. Can you see a value in the texbox while you are editing the form?

Finally, is the table buffered? If so, are you issuing a TABLEUPDATE() to explicitly save the changes?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
As Mike said REPLACE by default works on the current record. So your code isn't wrong, but if you change record 1 it points to not locating the record you want to change, record 1 is the current record, if you open a table, not the last record.

So if you want to change the last record you would need to GO BOTTOM. Your try with locate could work, but if FOUND() is false you will need to see why the value typed in doesn't match a record. If Found() is false, you're positioned at the EOF, after the last record and REPLACE won't do anything in that case.

Bye, Olaf.

 
By the way, the current record will be the last/latest record right after you do an INSERT INTO item_tbl (field list) VALUES (value list) or APPEND BLANK.
The current record can also be chosen, if you display the table in a grid. Selecting a grid row then moves the record pointer.

Your problem might be your doing selection and replace in different forms with different datasessions or at least different work areas. The concept of a current record, a record pointer is the concept of a work area, not of the table, so having a table opened twice or more, different forms/users/parts of your code can point to different records in the same table.

Bye, Olaf.

 
here is my code in selecting the picture

x = getpict()
if ! empty (x)
select item_table
SET ORDER TO itm_id
replace image WITH x
this.picture=item_table.image
[highlight #EF2929]thisform.refresh[/highlight]
ENDIF

thanks for your replies. found i that it was my refresh on the form...
 
Good you found the reason the form doesn't refresh.
Of course that needs a refresh, that'll sometimes work delayed, but is sufficient, as the form goes into an idle state after finishing this click event.
If you want to force the refreh you could do THISFORM.CLS() instead.

I assumed you are looking into a browse of the table to verify what and if a record was updated and which one. If you do open a browse right before executing that it would also explain you you're in record 1.

Just one question: Why do you SET ORDER TO itm_id?
No command here is making use of this sort order or index.

Bye, Olaf.
 
i forgot to remove it since i use locate earlier.sorry..
 
Fine, it just irritates.

By the way, even LOCATE will not need the SET ORDER, it will not use or prefer the currently active index, it'll analyze the FOR clause (with Rushmore) to see which index or indexes can be used to optimize the condition(s). You'd only need to set order to sort data display or to use the SEEK and SET KEY commands.

Bye, Olaf.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top