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!

insert menu bar replace not working 2

Status
Not open for further replies.

taterday

Programmer
Jan 28, 2009
183
US
In a memo field -- I added a find and replace. This is done by right clicking on the memo field, short menu will show the find and replace and etc for selecting. At that point any info that has been keyed will be erased/removed automatic. I have a table update prior to "Do menu ..." The memo field control source is the table.

I know this is something I should be seeing.

Please help.

Thank you.
 
Well, a memo field is part of the table and this has no controlsource, a textbox has a controlsource. So what are you talking about?

The natural control for a memo field is an editbox, not a textbox. If you talk about a grid displaying a memo, what you need is put an editbox in the column and make it the currentcontrol, also set sparse = .f. for that column to display the editbox in all rows, not only the active row.

Then you can add a context menu and put standard items in it, but this does not automatically find&replace within the editbox. Such edit system menu items simply work on the focused control content.

Bye, Olaf.
 
What to you mean by:

any info that has been keyed will be erased/removed automatic.

Are you talking about the text in the memo field, or the contents or the Find dialogue?

And

a short menu will show the find and replace and etc for selecting.

What do you mean by that? Are there items on the menu saying Find and Replace? Do they lead to the standard Find dialogues? Does the problem occur at the point of right-clicking, or when the dialogue(s) open?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Are you talking about the text in the memo field, or the contents or the Find dialogue? Contents of the memo field recently typed will be removed. The old data is still there.


The short cut menu is a
prompt "Find"
result Bar #
_med_find

(same with replace)

The memo field class is editbox located on a pageframe, controlsource is the table field.

Does this answer your questions?
 
Hm,

if what was recently typed is deleted for whatever reason, it looks like the current value of the editbox isn't saved yet to the memo field and the editbox is refreshed with the old nonupdates content as it still is stored in the dbf.

What kind of controlsource do you use? The table itself, a view? How is the buffering of the alias set - Cursorgetprop("Buffering", getwordnum(editbox.controlsource,1,"."))? If you use any buffering, try to do This.setfocus() to save the editbox.value to the table buffer and tableupdate(.F.) to sve the current record to the dbf before showing the context menu.

Bye, Olaf.
 

What kind of controlsource do you use? The table itself

****************
I have this statement after opening the pfs table

CursorSetProp("Buffering", 2, "pfs")
****************

I have this command prior to doing the short menu in the right click event.


SELECT pfs

Tableupdate(.F.,.T.,'pfs')

DO fdoc.mpr

*******************************
then new typing is removed.



 
Taterday,

Have you checked the reply from TABLEUPDATE()?

If TABLEUPDATE() cannot commit the update for any reason, it will return .F. You should check for that, and then use AERROR() to find out what went wrong.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
I think it is not the mpr removing changes. Either Mike is right and the tableupdate filas for some reason or you even have not yet stored the changes in the editbox value to the dbf buffer.

You have a three staged processing:

dbf - stage 1 - data really stored
dbf buffer - stage 2 - buffered changes pending to be stored in the dbf
control.value - stage 3 - value of the control, pending to be stored back to it's controlsource.

The control.value is written to the dbf buffer the moment you leave it, and valid event runs, not beforehand. Therefore you seem to not even have updated the buffer before doing tableupdate() and therefor revert to the old value.

Do as I said and add this.setfocus() beforehand, eg before calling the mpr do:

Code:
this.setfocus()
SELECT pfs
Tableupdate(.F.,.T.,'pfs')
DO fdoc.mpr

even though the editbox already has the focus, this will trigger to get through the event loop of losing focus, validating and then storing control.value into pfs.memofield from where it's stored to the dbf via tableupdate().

Bye, Olaf.
 
I added the this.setfocus before the update and it worked! Never occurred to me that it was a focus problem.

thank you guys. My problem has been solved.

Bye
 
It's not a focus problem, setting the focus just triggers the storing of the editbox value as by that setfocus you go through lostfocus, validate, then and only then the current value is stored to the dbf buffer and afterwards you reenter the editbox via when, gotfocus. That cascade of events is needed to save the current control value and is triggered by setfocus.

You'll have the same problem, if saving data via a toolbar save button, as that also does not move the focus from the current active control and saves all data minus the changes in that control.

it's not each keypress, which triggers the value to be written back to the controlsource of an editbox or textbox, it's passing both valid and lostfocus event.

Bye, Olaf.
 
THANK You. I will save this info for now and in the future. I know I have problems with the events firing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top