shanmugamgsn
shanmugamgsn

Reputation: 840

Add combo box dynamically in MS Access forms

I'm trying to create a form in MS access. Initially i will have only one combo box. My requirement is i have "Add" button if i click on this button this should dynamically add Combo boxes one below another.

My actual requirement is as follows: I designed this form like tender reply form

Usually a tender will have date, Item descriptions, quantity etc....

I have got this date using date() function. But this Item descriptions are already in database but there may be situations to add new item to database . I have to fetch from it or add into it if its new.

Am i clear with my explanations? Please help guys

exact thing i want is : wanna use a combo box for both, to add to database as well to fetch from database.

but inserting value to DB from combo box should not delete old record

Thanks, Shanmugam

Upvotes: 2

Views: 2123

Answers (1)

HansUp
HansUp

Reputation: 97101

Use the CreateControl Method with acComboBox (value = 111) as control type.

If you want the new combo box to appear below the last, you'll need to determine the position of the last one so you can then compute the appropriate .left and .top properties for the new one.

But there will be considerably more overhead to create a combo at runtime. In order for it to be useful, you will need to set a host of other properties, including: Row Source Type; Row Source; Bound Column; Control Source (if it will be a bound combo); Column Count; Column Widths. And probably still more. This task is more complicated than it may seem at first blush, and there are many opportunities for errors.

Personally, I've never found a situation where it seemed worth the effort. But I don't mean to imply it doesn't make sense in your situation.

Upvotes: 1

Related Questions