Populate a ComboBox w/ query results from other ComboBox, DateEdit, Memo, etc
I have a Dialog page with a Memo and two DateEdit boxes. A query is run based on a client # from the memo and a date range from the two DateEdits.
The query works and the report runs OK.
Now, I want to update the page to populate a ComboBox using the results of that query as parameters instead of running the report. The report would then be run based on the selection in the ComboBox.
Can that be done? Which event can I use to execute the query that accepts parameters from the first query?
I attached a screen shot. I would like to run a query using Client # and the two dates. Then the ComboBox at the bottom beside "Select Survey" would be populated with a query based on the previous query.
Both queries work. I just need to know how to populate the ComboBox.
Let me know if I need to clarify.
Thanks
The query works and the report runs OK.
Now, I want to update the page to populate a ComboBox using the results of that query as parameters instead of running the report. The report would then be run based on the selection in the ComboBox.
Can that be done? Which event can I use to execute the query that accepts parameters from the first query?
I attached a screen shot. I would like to run a query using Client # and the two dates. Then the ComboBox at the bottom beside "Select Survey" would be populated with a query based on the previous query.
Both queries work. I just need to know how to populate the ComboBox.
Let me know if I need to clarify.
Thanks
Comments
Is there a way to refresh the page after it is loaded and populate the ComboBox at that time?
Maybe I could call an OnShow event when the second date is entered?
I don't know. I'll take any suggestions.
I'm also open to moving the ComboBox to a 2nd DialogPage if that is a better option.
The box does populate correctly, but the report crashes when the OK button on DialogPage2 is clicked.
Does anyone know why I have to click the OK button twice?
I would still like to know if there is a way to get it working by just using one DialogPage. I would somehow need to activate the ComboBox or refresh the page after entering the 2 dates and the Client #.
Please let me know if you have suggestions.
I'll try my original question again.
Is there a way to refresh a ComboBox after a dialog page loads? Is there an event/action I can call to reload the ComboBox? I want the ComboBox to load from a query that accepts parameters from a memo and two dates selected on the same page. I might call whatever command I need from a button or from an event from another object on the page. It is not enough to have AutoOpenDataSet set to true since the page is already loaded before the parameters are selected. It is also not enough to simply execute the query connected to the ComboBox.
Please let me know if I need to clarify. Thanks.
and disable the ok btn you may also want to add a cancel btn
make sure the creation orfer of the objects follows the correct path.
look at using the onenter onexit events of each object to acheive what you want
I do have the OK button disabled.
I'm still not sure how to load the combobox from whatever event I use.
I was hoping for a command similar to what's used in .net - DBLookupComboBox.FillData();
There might not be a command similar to that.
I did find this code in the demo for loading a CheckListBox:
.Items and .Add are not properties of a ComboBox.
Is there anything similar that can be used for a ComboBox?
I'm also not yet sure how to set the creation order of the objects. I'll see if I can find that.
I suppose I could try using a CheckListBox instead of the combo.
Now I have to figure out how to pass that value to another query that creates the report.
With the ComboBox, I was using KeyField under properties as a parameter in the main query.
The properties of the query has a param defined as DBLookupComboBox1.keyvalue.
With the checklistbox, I'll have to define a param for the query with something like CheckListBox.text or CheckListBox.value.
I haven't found the correct syntax yet
Thanks for all the suggestions.
also take a look at the main demo dialogs and script- coosing records to print
Even if I do find it, I'll have to extract the part used as the param. Each row in the CheckListBox will have 3 columns from the table selected in the query.
One column is a date, another is a name, and the 3rd will be a foreign key used as the param in the data band query. So each row in the CheckListBox will have date + name + foreign key. I will have to extract the foreign key.
With a DBLookupComboBox, I don't need to include the foreign key in the list. I just set the KeyField to the foreign key and use the KeyValue of the combobox as the param.
The user only needs to see the date and name.
I'm not sure if I'm explaining it clearly.
The problem I'm having with that approach - the first dialogpage stays open behind the second dialogpage. The OK button on the second page has to be clicked twice. The first click closes the first dialogpage. The second click runs the report. It works, but it doesn't look good having to click the OK button twice.
I solved the above problem. In the click event of DialogPage1 I had coded:
DialogPage2.ShowModal;
I thought I needed that to call DialogPage2. It is unnecessary and was causing DialogPage1 to stay open in the background.
I can use the report that way but would still like to know how to load a DBLookupComboBox after the DialogPage has already loaded.
Thanks for the suggestions.