In AX 2009, if I create a custom lookup for a textbox field, it works fine
if the user clicks the lookup button, but if you use the lookup shortcut key
(*), the form moves to the back behind the main ax window. Does anyone know
why this is and if there's a way to fix this?
Thanks,
Adam
P.S., here's an example of the code I'm using...
// text box lookup method
public void lookup()
{
super();
MyTable::lookupField(this, "ABC");
}
// lookup method on MyTable which displays values based on another value
public static void lookupField(FormStringControl _ctrl, str _value)
{
SysTableLookup lookup = SysTableLookup::newParameters(tablenum(MyTable),
_ctrl);
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(tablenum(MyTable));
QueryBuildRange qbr = qbds.addRange(fieldnum(MyTable, MyField));
;
if(!_value)
throw error("Please enter a value in that other field");
qbr.value(_value);
lookup.addLookupField(fieldnum(MyTable, MyField));
lookup.addLookupField(fieldnum(MyTable, MyOtherField));
lookup.parmQuery(query);
lookup.performFormLookup();
}
Just seen one potential bug in your code. Don't know if this solves your
problem, but you can try:
You don't have to call super() in the lookup method; your static call
lookupField(..) should replace the super()-funcationality.
// text box lookup method
public void lookup()
{
// super();
MyTable::lookupField(this, "ABC");
}
May be that's it.
Regards
Patrick
Thanks a lot for looking at my code! You were right on target.
Thanks again,
Adam