View Full Version : Adding more combo boxes to a form


daveUK
03-17-2002, 03:26 AM
I have a database that allows users to store, categorize and view digital photographs. I'm creating a searchform to search the database by Category, Sub-Category or both. There are 3 combo boxes on the form which aren't visible to the user when the form is loaded and 3 checkboxes(Category, Sub-Category, Both). The user checks a checkbox and the relevant combo box is displayed. They then select a Category/Sub-Category/Both from the combo box, click a cmd button (which runs a query) and the relevant records are displayed. This is working OK. What I need to do is allow the user to click another cmd button, this will again give the user the choice of searching by Category/Sub-Category/Both and display another combo box. This will allow the user to search for 2 categories/sub-categories or a mixture of the 2 at once. I've been told that there is a way of adding combo boxes dynamically but I can't seem to find out anything about it.

I hope I've explained this clearly http://www.access-programmers.co.uk/ubb/biggrin.gif

Dave

Pat Hartman
03-17-2002, 07:54 AM
I don't think that adding combo boxes dynamically is the answer. A better approach would be to use multi-select list boxes. This would require some programming on your part since you would need to build the Where clause of your query dynamically based on the selections made. This has been described on the forum many times. Coding samples are also available from the Microsoft knowledge base. It is also complicated somewhat by the variation of a one or two tiered search. When a two tiered select is necessary, the list box would need to concatinate the category and sub-category elements and your code would need to split them appart to properly construct the where clause.

daveUK
03-17-2002, 09:58 AM
Thanks Pat,

I've managed to just about get it working by having lots of combo boxes on the form and setting their visible property to false until a command button is pressed.
It's probably not the best way to do it, but at least it works http://www.access-programmers.co.uk/ubb/biggrin.gif


[This message has been edited by daveUK (edited 03-17-2002).]