Subject Re: QUERY ON FORM
From Heinz Kesting <Nobody@Nowhere.com>
Date Sat, 20 Jan 2018 23:15:23 +0100
Newsgroups dbase.getting-started

Hi Mustansir,

> I have put  following statement on form_open() method (xyz.dbf has fields code, name)
>
> mq1 = new query()
> mq1.sql = select * from c:xyz"
> mq1.active = true
>
> when I refer to this query later in the form with following statement it says variable mq1 undefined
>
> form.mq2,rowset,fields["item"].lookuprowset = mq1.rowset
>

I can see two possible issues.
First, in your form_onOpen() you should declare the query mq1 as a
property of the form if you want to refer to it later from other
functions, like:

form.mq1 = new query()
form.mq1.sql = select * from c:xyz"
form.mq1.active = true

This way mq1 is available to all functions of this form. Otherwise it is
only available in the onOpen() function itself.

Second, mind the difference between dots and commas. If it isn't a typo
while writing this post, the line

form.mq2,rowset,fields["item"].lookuprowset = mq1.rowset

should read

form.mq2.rowset.fields["item"].lookuprowset = mq1.rowset

Hope I could help.
Kind regards, Heinz