Subject Re: applylocate not working
From Mervyn Bick <invalid@invalid.invalid>
Date Sat, 8 Jun 2024 11:40:37 +0200
Newsgroups dbase.getting-started

On 2024/06/07 16:43, Charlie wrote:
> I thought this would be easy since I have done this before but the apply locate is never found.  tgrade is what i am trying to find.  actually it represents a field in the table.  so that isn't the problem (yet) because this never finds tid and cat which are also strings.
>
> i have tried this looking for bith variables and only one which certainly should have been found, but for some reason the applylocate doesn't work.
>
> Can anyone help?
>
>
>
>
>
>   function COMBOBOX4_onChange()
>            co = form.coins1.rowset
>            tgrade = trim(form.combobox4.value)
>                 tid = trim(form.entryfield5.value)
>                 tcat= trim(form.combobox2.value)
>                 //co.applylocate("year= '" + tid + "'")// and category= '" + tcat + "'")
>                 co.applylocate( "year= '" + 'tid' + "' and category= '" + tcat + "'")
>                 form.entryfield1.value = val(co.fields["&tgrade."].value)
>                 //if found()
>                    msgbox( ""+found() )

Found() is an XDML function that only works on a table opened in a
workarea by the USE command.  ApplyLocate() returns true or false to
indicate success.  See the modified code below.

Try the following. It is partially tested as the coins.dbf file you sent
me some time ago does not include character fields with grade details.
Your code display the grade does, however, look OK.

  function COMBOBOX4_onChange()
       co = form.coins1.rowset
       co.locateOptions:= 3
       tgrade = trim(form.combobox4.value)
       tid = trim(form.entryfield5.value)
       tcat= trim(form.combobox2.value)
       bFound = co.applylocate("year = '" + tid + "' and category = '" +
tcat + "'")
       form.entryfield1.value = val(co.fields["&tgrade."].value)
//      if bFound
          msgbox( ""+bFound )
//      endif

Mervyn.