# Code is not loading the BAQCombo **Category:** [Epicor ERP 10](https://www.epiusers.help/c/e10/5) **Created:** 2017-01-20 17:35 UTC **Views:** 5729 **Replies:** 28 **URL:** https://www.epiusers.help/t/code-is-not-loading-the-baqcombo/36969 --- ## Post #1 by @Alex Guys i am using the code below to load information in a BAQComboBox. The issue is the following Example i create sales order let say 123 and i fill the information of the BAQComboBox. After i safe the sales order i load a different sales order lets say 456 then i go back and i load sales order 123 and the BAQCombobox is empty but if you click in the drop down arrow the value of the dropdown is selected but is didnt load with the screen. the BAQCombobox is binding the field Application_c. Please advise private static void oTrans_ordAdapter_AfterAdapterMethod(object sender, AfterAdapterMethodArgs args) { // ** Argument Properties and Uses ** // ** args.MethodName ** // ** Add Event Handler Code ** // ** Use MessageBox to find adapter method name EpiDataView edvOrderHed = ((EpiDataView)(Script.oTrans.EpiDataViews["OrderHed"])); switch (args.MethodName) { case "Update": baqComboC2.Value = edvOrderHed.dataView.Table.Columns["Application_c"]; break; } } --- ## Post #2 by @Aaron_Moreng Show us a screenshot of your BAQ Combo box properties, that's probably where the issue is. --- ## Post #3 by @Alex The BAQ Combo box labeled application is the one with the problem --- ## Post #4 by @Aaron_Moreng Not sure why you need after adapter method at all. Because your BAQ Combo is bound to the OrderHed.Application_c field, the value will always be in that control and will change when the data views change. --- ## Post #5 by @Alex The problem is the following When you open order entry the application baq drop down loads the values correctly without problems, but when order entry menu is already open, but you open a sales order then you load a different sales order the second sales order loaded it not loading the application field info but if you query the data base the field has information --- ## Post #6 by @Aaron_Moreng I really think the problem is the after adapter method event you added. There is no need for that as the BAQ Combo control handles all of that natively. Try commenting out the action in that method and see if it behaves differently. --- ## Post #7 by @Alex With out the event is when i have the problem i add this event to try to fix the problem and is not working either --- ## Post #8 by @Alex I commented the action and i still have the same problem --- ## Post #9 by @josecgomez Alex, What is your BAQ querying? Can you share a screenshot of your BAQ? You shouldn't need ANY code for a BAQ Combo to work. --- ## Post #10 by @Alex here is the pic of the BAQ --- ## Post #11 by @josecgomez ha! you are using BAQ Markup... I wonder if that doesn't work with UD fields... (not sure why it wouldn't)... can you remove the BAQ Markup and see if that works ok (meaning the value always populates even if its not filtered) --- ## Post #12 by @Alex let me try that give me a sec --- ## Post #13 by @Alex i removed the markup and now it works --- ## Post #14 by @Alex The question would be; how can i filtered and make the BAQ load? --- ## Post #15 by @josecgomez You can add the filter in code.... instead of in the BAQ Markup... on a BeforeDropDown Event --- ## Post #16 by @Alex ok thanks Jose really appreciated --- ## Post #17 by @Alex Jose i was watching your video on youtube on how to code a baq in a customization and i adapted to my code but i would like to know how do i assign the values to the drop down? The code i tried to use were the 2 lines commented at the end of the code. private static void epiComboC2_BeforeDropDown(object sender, System.ComponentModel.CancelEventArgs args) { // ** Place Event Handling Code Here ** DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans); dqa.BOConnect(); QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("EII-Cbx-UD102A-Application"); qeds.ExecutionParameter.Clear(); qeds.ExecutionParameter.AddExecutionParameterRow("Market", epiComboC1.Value.ToString(), "nvarchar", false, Guid.NewGuid(),"A"); dqa.ExecuteByID("EII-Cbx-UD102A-Application",qeds); //epiComboC2.ValueMember = dqa.QueryResults.Tables["Results"].Columns["UD102A_ChildKey1"]; //epiComboC2.DisplayMember =dqa.QueryResults.Tables["Results"].Columns["UD102A_Character01"]; } --- ## Post #18 by @josecgomez That should work, are you getting results back from the BAQ run? --- ## Post #19 by @Alex I checked the BAQ and it works. also i am getting this error when i dont comment the last 2 lines i get this error please advice. Error: CS0029 - line 279 (1218) - Cannot implicitly convert type 'System.Data.DataColumn' to 'string' Error: CS0029 - line 280 (1219) - Cannot implicitly convert type 'System.Data.DataColumn' to 'string' 270- private static void epiComboC2_BeforeDropDown(object sender, System.ComponentModel.CancelEventArgs args) 271- { 272 - // ** Place Event Handling Code Here ** 273 - DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans); 274 - dqa.BOConnect(); 275 - QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("EII-Cbx-UD102A-Application"); 276 - qeds.ExecutionParameter.Clear(); 277 - qeds.ExecutionParameter.AddExecutionParameterRow("Market", epiComboC1.Value.ToString(), "nvarchar", false, Guid.NewGuid(),"A"); 278 - dqa.ExecuteByID("EII-Cbx-UD102A-Application",qeds); 279 - epiComboC2.ValueMember = dqa.QueryResults.Tables["Results"].Columns["UD102A_ChildKey1"]; 280 - epiComboC2.DisplayMember = dqa.QueryResults.Tables["Results"].Columns["UD102A_Character01"]; } --- ## Post #20 by @Alex Jose, could you please look at line 279 and 280 and let me know what i have wrong? --- ## Post #21 by @josecgomez That all looks fine, do you now if there are results in your QueryResult table? Run MessageBox.Show(dqa.QueryResults.Tables["Results"].Rows.Count()); on line 279 --- ## Post #22 by @Alex i added the line and i get this resoult --- ## Post #23 by @josecgomez Oh wai.. I didn't look at the code carefully.. You are assigning the columns to the grid... not the value. Try this ```cs epiComboC2.DataSource = dqa.eryQuResults.Tables["Results"]; epiComboC2.ValueMember = "UD102A_ChildKey1"; epiComboC2.DisplayMember = "UD102A_Character01"; ``` --- ## Post #24 by @Alex When i try that code, the combo box get grayed out. Should i use an Ultra ComboBox? --- ## Post #25 by @josecgomez In the ComoBox Box properties set False to Retrieve on Activate. --- ## Post #26 by @Alex Thanks so much it works gratefully --- ## Post #27 by @TomAlexander [quote="josecgomez, post:11, topic:36969, full:true"] ha! you are using BAQ Markup… I wonder if that doesn’t work with UD fields… (not sure why it wouldn’t)… can you remove the BAQ Markup and see if that works ok (meaning the value always populates even if its not filtered) [/quote] Running into the same thing with a BAQCombo.. works perfectly but doesn't refresh the display when switching between multiple customers in Customer Entry. I am too stubborn to reimplement the whole thing with an EpiCombo... Any ideas for force refreshing the BAQCombo? Oddly I don't even see BAQCombo in the Object Explorer so I'm not sure what methods I can use to attack it.. --- ## Post #28 by @josecgomez There is a ForceRefresh call you can make on the combo itself Something like refresh list it’s been a minute `using` `System.Reflection;` `public` `void` `InitializeCustomCode()` `{` ` ` `myCombo= (BAQCombo)csm.GetNativeControlReference(` `"42dd2f96-d122-4e38-a745-2cce674154c7"` `);` ` ` `myCombo.BeforeDropDown += ` `new` `System.ComponentModel.CancelEventHandler(` `this` `.myCombo_BeforeDropDown);` `}` `public` `void` `DestroyCustomCode()` `{` ` ` `myCombo.BeforeDropDown -= ` `new` `System.ComponentModel.CancelEventHandler(` `this` `.myCombo_BeforeDropDown);` `}` ` ` `private` `void` `myCombo_BeforeDropDown(` `object` `sender, System.ComponentModel.CancelEventArgs args)` ` ` `{` ` ` `// ** Place Event Handling Code Here **` ` ` `RedfreshBAQCombo(myCombo);` ` ` `}` ` ` `private` `void` `RedfreshBAQCombo(BAQCombo cbo)` ` ` `{` ` ` `var field = cbo.GetType().GetField(` `"_baqResults"` `, BindingFlags.NonPublic | BindingFlags.Instance);` ` ` `field.SetValue(cbo, ` `null` `);` ` ` `var method = cbo.GetType().GetMethod(` `"LoadBaqList"` `, BindingFlags.NonPublic | BindingFlags.Instance);` ` ` `method.Invoke(cbo, ` `null` `);` ` ` `cbo.RetrieveOnActivate = ` `true` `;` ` ` `cbo.ForceRefreshList();` ` ` `}` --- ## Post #29 by @TomAlexander Omg that worked. Thank you! I was literally going down the path of sending mouse clicks to click the dropdown and then tab off... thank you for saving me from that. --- **Canonical:** https://www.epiusers.help/t/code-is-not-loading-the-baqcombo/36969 **Original content:** https://www.epiusers.help/t/code-is-not-loading-the-baqcombo/36969