QueryRun is used in outer scope

Hi All,

I am getting a error message? QueryRun is used in outer Scopet.

Error I have declared inside the class declaration. It shows the same error message.

after removing and I have written inside the fetch method. How to identify. Where the QueryRun object is initialized

I am using in ax 2009 reports.

public boolean fetch()

{

boolean ret;

;

if (!queryRun.prompt())

{

return false;

}

else

{

while(queryRun.next())

{

while select firstonly meterTypMaster index hint TypeMasterIdx

where electricalMeterMaster.TypeIdentification == meterTypMaster.TypeIdentification && meterTypMaster.SelectType == selectType::Other

{

info(strfmt("%1",electricalMeterMaster.RecId));

while select electricalMeterMaster index hint MeterMaster order by MeterNumber group by MeterNumber where electricalMeterMaster.TypeIdentification == meterTypMaster.TypeIdentification

outer join electricalOtherPlant where electricalOtherPlant.MeterNumber == electricalMeterMaster.MeterNumber

{

element.send(electricalOtherPlant);

}

}

}

}

return false;

}

I want to acheive filtering based on the prior condition. It must shows only the values based on the prior condition…It shows all the values and miss match the values shows…

Wrong Argument type is used in the Assignment

You mentioned three different errors:

  • QueryRun is used in outer scope
  • Wrong Argument type is used in the Assignment
  • It shows all the values and miss match the values shows

Please make clear which problem you want to talk about and describe it in detail, such as which line of code throws the error.

By the way, please don’t prefix your thread titles with "re : " and separate tags by comma or semicolon.

Hi Martin,

Its shows the error Query Run is used in Outer Scope,if I declare in the report declaration.

If I remove that…Query run…It works fine.But when I select the value from the Dialog form

  1. From date

  2. To date

3 . When I select the Type … Plant

It should show only values to the Plant…But It also shows type : Other Values…that’s why miss match of value.

Like example !! when you select a country…it will show the state in the country…when right values matches it will show the report…

Wrong values means…IT will show Wrong Argument on Assignment …I am working on AX 2009.

You ignore what I told you… All right, so I’ll explain the error in the title and will consider everything else off-topic.

You didn’t write down the error message correctly, because it refers to a variable name and it can’t contain spaces. I assume that the message was “queryRun is used in outer scope”. It means that you tried to declare a variable called queryRun, but the report already has another variable of the same name (declared in ClassDeclaration). You have to use another name for your variable.

Martin, Its not thing. Actually I was working in VAR layer earlier. The same data is moved to USR layer.

I have check the QueryRun has declared in the Class definition.But it is not there.

I don’t know where the variable resides. But What I did is !! I have try to delete all the data by going to Tools >> Options >> Usage Data to Reset the values to Null and check again.What you said is exactly right. I accept that. But when It is not found in Class Declaration. Where exactly it will stay.

I have one more query that, When I select a value through a Dialog Field… the next value must be selected based on the previous values and right matching value through Dialog Field.

By time,It shows Wrong Arguments with Assignment.

Thanks Martin,You supports lot of people like me.

It must be declared somewhere; maybe it’s in a parent class. If you tell me where exactly you have your code (no such a declaration is in your code above), I might be able to tell you where the variable comes from.

Hi Martin,

I have create such a way in ax 2009 report. It is a AX 2009 version report.

I have report…Inside the report…based on Query…I have attached 3 datasource to the report…

First 2 datasource are used by Inner join and the 3 data source by Outer join…first and second datasources have common relations…2 and 3 datasources have common relations.

In query Declaration under report…I didn’t write any code.

In the Fetch method…I am writing The QueryRun declaration. I have written condition for filtering it…

There is no errors…when Dialog based form is opens…

From date given,To date given…and Type Identication is a shows all the data…

For my condition …on the first table…the field TypeIdentication and Select Type as Base enum is used.

2nd table Type Identification with other parameters are there?

when I click the Type Identication it shows all the values…

example …

Type identification select type

1 plant

2 other

3 plant

4 other.

On my requirement …

when I select Type identifcation as !, it should select only correponding values…from the next filter values

but I shows all…Even I run that…I shows

Wrong Arguments type on assignment and it not shows the values in the report