I have a UD field on the OrderHed table that holds a string. I only want the users to be limited in selecting a value from a dropdown.
The dropdown on the Order Entry screen populates properly, including a filter based on a field “Inactive_c” in the UD table. If I set the Inactive_c field in the UD table, that entry doesn’t appear in the dropdown. This is exactly what I want.
However, if the UD table record gets marked Inactive, opening an Order that uses that no-longer active record, the field is blanked out instead of showing the old (but valid) value.
Hmm, I’ve not used a UD table to populate a combo, we’ve always used UserCodes we have added UD fields to that table though to cover some related data needs.
Here’s the code to populate the GUI dropdown scbRegion, with entries from table UD06. If UD06.Checkbox01 is true (i.e our “InActive” flag), that record is not added to the dropdown.
However, if the UD table record gets marked Inactive, opening an Order that uses that no-longer active record, the field is blanked out instead of showing the old (but valid) value.
Yeah a if or where clause may work out so just display the value set on the Order table field even if it’s not a valid item in the combo list. The assumption would be the code was valid before and not “bad” data.
Excluding the fancy EpiBinding ways - you could easily query the UD table with the appropriate adapter and where clause, pipe results to a list or dataset then set that as the datasource for the combo.
Also your last comment about the where clause should also work.
Sure, first get/import the proper UD adapter, instanciate it, connect it.
Then call a getrows with the appropriate where clause for your needs.
Finally set it as the combo datasource.
UD39Adapter a = new UD39Adapter();
a.BOConnect();
SearchOptions opts = new SearchOptions(SearchMode.AutoSearch);
opts.NamedSearch.WhereClauses.Add("UD39", "Key4 in ('M1','M2')");
bool more = false;
DataSet ds = a.GetRows(opts, out more);
MyCombo.DataSource = ds;
Also, you could probably use a binding source for filtering:
BindingSource JobBs = new BindingSource();
LabelBs.DataSource = ds;
JobBs.Filter = string.Format("JobOpDtl_ResourceID IN ({0})", getSelectionString(ACell));