Subject Re: replace command
From Gaetano D. <gaetanodd@hotmail.com>
Date Sat, 1 May 2021 17:28:32 +1000
Newsgroups dbase.getting-started

On 1/05/2021 17:03, AGOSTINHO wrote:
> Dear Group
> This does not seem to work, please how to make it work?
> Thanks
>  
>    this.rowset = this.clients1.rowset
>
>     function ENTRYFIELD3_onChange()
>        if form.entryfield3.value=0.00
>                   replace form.rowset.fields["cc"].value with "CASH"
>            endif
>        return
>
I would avoid to mix OODML and XML, since you use a rowset, forget about "replace", jsut assign the value to the field object.

It might also be a good idea to rename the entryfields to something you can more easily rememeber, e.g. this.EF_SalesPrice is a new entryfield(this)

That being said, I am not sure that the entryfield knows about the "form" object. You can try this:


this.rowset = this.clients1.rowset

    function ENTRYFIELD3_onChange()
       if form.entryfield3.value=0.00
          form.rowset.fields["cc"].value ="CASH"
          form.rowset.save()
 endif
       return


but I think you need to use the "parent" hierarchy to get to the form's rowset:

function ENTRYFIELD3_onChange()
       if this.parent.entryfield3.value=0.00 // in this function, you are at the entryfield level of the hierarchy, the parent of the entryfield is the form - unless it's in a container, in that case, you need to go one more parent up...
          this.parent.rowset.fields["cc"].value ="CASH"
          this.parent.rowset.save()
 endif
       return