editbox programmatic change

I am looking for an easy way to determine if I've made interactive change in an editor box. The issue is that there are about 16 controls on a container, they are initialized from a table record thus their values at activate time generally are not trivial default. I have to save the changes with a SAVE button if I made any but I want this button's click method to quickly determine which control values have been changed. I do not want to do REPLACE for the fields with values that haven't been changed.

In case of simple controls like a combobox I can store the initial value in Tag property and do the comparison programmatically. Sometimes the editbox contents are quite large and I am hesitant to do it. There should be a better way I cannot see.

I have the same problem with RTFControls.

I would appreciate any suggestions.

Thanks.




Answer this question

editbox programmatic change

  • koh

    So far no good. I haven't been able to make it work.

    FOR ii = 1 TO THIS.Parent.Parent.CT4.Objects.Count
    TRY
    THIS.Parent.Parent.CT4.Objects(ii).SetFocus ()
    KEYBOARD '{LEFTMOUSE}'
    CATCH
    ENDTRY
    ENDFOR

    The try..catch..entry block is needed because there are 26 controls overall but only about half of them can take focus.

    I have to kick every control with my mouse to make changes visible after this statement is executed. Otherwise I may be under the impression that the values haven't changed at all.

    The old ways of Visual dBase may not be so bad after all.



  • Brendan McLoughlin

    Try changing those code of lines with:

    thisform.refresh()


  • DigitalMan2112

    Another small problem. If the field value is empty: { / / } for a date type field then date/time picker throws an exception.

  • Tony Bass

    You know, I should not have written that post. The values do change, it turns out. The controls need a click with the mouse to assume a new value. I do it for date/time pickers with KEYBOARD {'RIGHTMOUSE'} each separately but I put them into focus first: picker.SetFocus ().

    Can I do the same operation with SetAll () since now I will have to do it on every control

    Thanks a lot.



  • bciampa

    DateTimePicker control doesn't work with empty date. Set to null instead of empty datetime.
  • Debjit

    Wow! It works. !!!!!!!!!!

    Thank you very much, Cetin. You are a genius.



  • Bob Kilbertus

    Well, the trouble for me is that some of my records do have unassigned dates by omission or otherwise. How am I going to handle it with the exceptions thrown out every time they run into them The OLE seems to say that the value is outside of defined range between min and max

    The Date and Time Picker is the only contol where you want to do the data updates manually because, as Cetin said, you cannot bind those controls to empty dates. If you are using empty dates (instead of null), then you have to do manual updating when using this control/



  • Mansatan

    Well, the trouble for me is that some of my records do have unassigned dates by omission or otherwise. How am I going to handle it with the exceptions thrown out every time they run into them The OLE seems to say that the value is outside of defined range between min and max.

  • Justin Lindh

    I am looking for an easy way to determine if I've made interactive change in an editor box. The issue is that there are about 16 controls on a container, they are initialized from a table record thus their values at activate time generally are not trivial default. I have to save the changes with a SAVE button if I made any but I want this button's click method to quickly determine which control values have been changed. I do not want to do REPLACE for the fields with values that haven't been changed.

    I take it then, that these controls are all unbound controls (i.e., their ControlSources are empty) and that you are manually updating their values and saving the values to the underlying data (Just like we used to do in the old days before Visual FoxPro and the advent of buffering with SCATTER and GATHER).

    Why don't you just use buffered data and bind your controls You would save yourself from having to write an awful lot of code. The data does not get committed to the table until you issue a successful TABLEUPDATE(). Also, of you really needed to check to see if something has changed you could use these functions:

    OLDVAL() - Value of the field when you pulled the record into your buffer

    CURVAL() - Value of the field as it is currently in the table on disk

    You could also use GETFLDSTATE() to determine if this is a newly added or modified record.



  • rose-marie

    I think I found a compromise. It seems to be working when I use both ControlSource property and also assign the value to the controls programmatically. It may be still a better solution than I had before since at the time when I save the changes I won't have to mess with comparing the stored values with controls but use your suggested functions.

    Thanks.



  • dotDavid

    Come to think of it! You are absolutely right in your assumption. I am not using the ControlSource property. Perhaps I should have. The old ways of dBase are too ingraned in me.

    I should try it. Thank you.



  • Dwarvend

    I just tried it. If it is gonna work it will be great, It will save me tons of trouble. I am willing to rewrite pages of code.

    So far it is not quite working. I am testing it on a few fields: one spinner (amount), one memo and a few textboxes. I defined the ControlSource Property as payments.memo1 for instance for the editbox.

    The amount field (spinner) takes the value but only the FIRST time. When I try to change the records the value of this field DOES NOT change. I want to explain how I change the records. I have a treeview with nodes. I highlight one of them I know reflects an instance of payment. Then I click another button to make a container with all controls visible. The click method for this button finds the record via IF SEEK () method and (in my old way) assigns the field values to the controls. Now I blocked a few statements that assigned those value and I know for a fact that the records for the controlSource are changing but the values for ALL controls are not changing at all after the first record.

    What am I missing

    In addition to this trouble the memo field does not appear in the editbox at all even at the first attempt with the first record attached.

    What am I missing here

    You are amazing in your quick response.

    Thanks.



  • arithie

    It should have been 'LEFTMOUSE.' Anyway, the problem now is to find a way to kick all controls with one command if posible to wake them up to a new record. As I said I do it for the pickers--without it they do not become visible.

  • Sarah c

    You mean picker.month = NULL, picker.day = NULL, etc

  • editbox programmatic change