This topic is locked

Filtering values in lookup wizard

10/14/2012 12:36:25 AM
PHPRunner General questions
B
btrdev author

I have 2 related tables - let's call them OrderH and OrderD.
In my OrderH table the primary key is OrderNum, but I also have a column called OrderType.
The type of items that can be placed on an order depend on the OrderType value.
When creating a new order and adding items to the OrderD table, I want to use a lookup, so that the items to be added are selected from a table called ItemList.
There is also an OrderType column in the Itemlist table, and for any order, items can only be added to the order if the ItemList.OrderType = OrderH.OrderType
Therefore, when creating an order, the user will first create a header and specify the Order Type. When entering details for the order, the user should only be able to select items where the OrderType corresponds to the header record.
How can I construct a WHERE clause in the Lookup Wizard so that it only displays these records?
Any suggestions would be appreciated.

Sergey Kornilov admin 10/15/2012

This would be a two step process.

  1. You need to save the value of OrderType field in the session variable like $_SESSION["OrderType"].
  2. Add a WHERE clause to your lookup wizard control like this:

" OrderType=".$_SESSION["OrderType"]



or

" OrderType='".$_SESSION["OrderType"]."'"



Use second expression if OrderType field is the text one.

B
btrdev author 10/17/2012

Thanks. I'll try this and see how it works.



This would be a two step process.

  1. You need to save the value of OrderType field in the session variable like $_SESSION["OrderType"].
  2. Add a WHERE clause to your lookup wizard control like this:

" OrderType=".$_SESSION["OrderType"]



or

" OrderType='".$_SESSION["OrderType"]."'"



Use second expression if OrderType field is the text one.