ulisses
ulisses

Reputation: 1581

Why I have Field dataAreaId Access denied in a Query?

I have a problem, I used in my init Form a little Query. I used this code :

query q = new Query();
QueryBuildDataSource qbds;
QueryRun queryRun;
qbds.addRange(fieldNum(MyTable,dataAreaId)).value(SysQuery::valueUnlimited());
queryRun = new queryRun(q);
if (! queryRun.prompt())
{
     element.close();
}
MyTable_ds.query(queryRun.query());

When I insered a value in my query prompt I will have a error message :

"Can not select the Company field."

I have in my Design and dataSource this field , but I can't use in a Query. All other fields I can use without problems.

It's possible to use this field in a query?

Thanks your time,

enjoy!

Upvotes: 0

Views: 797

Answers (1)

Maxim Lazarev
Maxim Lazarev

Reputation: 1254

You cannot include DataAreaId in your queries.

You can however use addCompanyRange method on your query:

q.addCompanyRange("dat");

Try this:

query q = new Query();
QueryBuildDataSource qbds;   
QueryRun queryRun;

qbds = q.addDataSource("MyTable");
//Build you query 

q.allowCrossCompany(true);
q.addCompanyRange("dat");

queryRun = new queryRun(q);
if (! queryRun.prompt())
{
    element.close();
}
MyTable_ds.query(queryRun.query());

Upvotes: 2

Related Questions