Subject Re: function form_onNavigate(nWorkArea)
From Mervyn Bick <invalid@invalid.invalid>
Date Mon, 10 May 2021 11:07:49 +0200
Newsgroups dbase.getting-started

On 2021/05/10 09:32, roy price wrote:
> This one's a mystery to me.
>
> My main table cactusaa, I have linked to a table Cactusaatext that
> contains a field "rec" that is the same as the "rec" field in the main
> table.
>
> The fields were text 4ch, but I changed them to numeric, 4ch.
>
> this function (which I understand is the syntax for a numeric field)
> produces a "database engine error".
>
> function form_onNavigate(nWorkArea)
> this.cactusaatext1.rowset.applyLocate( "rec = " +
> this.cactusaa1.rowset.fields['rec'].value  )
>

Please don't use the form's onNavigate event handler.  This was meant
for use with tables opened in workareas by using the XDML USE command.

You are using query objects to open your tables so need to use OODML
event handlers.

Mixing XDML and OODML can lead to problems and should, therefore, be
avoided.

In this case you need to use the cactusaa1.rowset's onNavigate event
handler to move the rowpointer in the cacusaatext1 rowset.

Any event handler associated with a query or a rowset does not
understand the concept of "form" so one needs to use this.parent.... to
work one's way back to the form.  In other words instead of
form.cactsaatext1.rowset.applyLocate() we need to use
this.parent.parent.cactsaatext1.rowset.applyLocate()



   function rowset_onNavigate(type, nRows)
       //onNavigate event handler for cactusaa1.rowset
       //where rec is numeric in both tables
       this.parent.parent.cactsaatext1.rowset.applyLocate( "rec = " +
this.fields['rec'].value )
       return

or


   function rowset_onNavigate(type, nRows)
       //onNavigate event handler for cactusaa1.rowset
       //where rec is character in both tables
       this.parent.parent.cactsaatext1.rowset.applyLocate( "rec = '" +
this.fields['rec'].value +"'")
       return


> This worked OK when the field was text, but now it still works, but only
> for when the contents of the field (4CH) are greater than "1000". IE,
> nothing under 1000 works.

Character fields are normally left justified in the field but this does
mean that an index on the field does not display the records in the
correct numeric sequence.

To make sure that an index displays the records in the correct sequence
one needs to pad the characters on their left side with enough spaces to
ensure that the values are right justified in the field.

If the contents of the rec fields in both tables are character they must
both be either left or right justified.  If they are not the same then
the applyLocate() will only work once you start working with 4
characters i.e when the fields are full.

Mervyn.