When to use the Control Source property of a Combo Box?

new2access123

Registered User.
Local time
Today, 12:14
Joined
Feb 5, 2010
Messages
12

I am teaching myself VBA and am creating a form in Access on which I use a combo box. I am able to return the desired value and hide columns etc. What I don't understand is the usefulness of the Control Source property . The Control Source property specifies what field in the in the Record Source the combo box is bound to. Since the Bound Column, Column Count and Column Widths are used to set what column will be shown and what value will be returned for a combo box., why would I "bind" to a column in the row source? What would I be trying to accomplish in doing that?

Thanks for the deucation
 
Hi,

i amy be wrong as ive had a long today today but, you are not limited to bounding the combo box to the field. you can assign its control source to a query or sql string. the biding of the field is merely an easy way for access users to get data. you can also change the content dynamically with VBA based on conditions if you wished say with a select statement
Code:
select Case MyVar As Variant

Case True
Me.MyCombo.ControlSource = "qryNumberOne"

Case False
Me.MyCombo.ControlSource = "QryNumberTwo"

Case Else

End Select

personally i like the changing of the ControlSource. mainly because i like to have 1 single interface with a changing orm embedded. as i flick through my menu, the form changes based on the main form ID showing other screens within the one form.

HTH


nigel
 
I think Nigel has it a little confused. You can change the Row Source on the fly, but normally you would not be changing the Bound property of any control. You use the Bound property to specify the field into which the returned value of the combo box or list box is to saved. In many cases the value returned by the combo box or list box will be key value from another table.

Using a combo box or a list box bound to a field is used to allow you the developer to present a specific list of values from which users can make selections, thus limiting the number of available values that can be entered into the bound field.

Hope this helps.
 
Hi

thought as much. Told you it was late lol


Nigel
 
Just to make sure I am understanding this correctly, for example, often times the control source of a combo box would be a field in a table other than the table in the row source of the cbo? So that when a selection is made in the cbo, the cbo value will populate the field specified in the control source.



I think Nigel has it a little confused. You can change the Row Source on the fly, but normally you would not be changing the Bound property of any control. You use the Bound property to specify the field into which the returned value of the combo box or list box is to saved. In many cases the value returned by the combo box or list box will be key value from another table.

Using a combo box or a list box bound to a field is used to allow you the developer to present a specific list of values from which users can make selections, thus limiting the number of available values that can be entered into the bound field.

Hope this helps.
 
Correct! Most of the time I will be populating a combo box with records from a table, returning the Key field from that table by having the key field as the bound field to the combo box and store that value in the table that is linked to the form, storing the key value as a foreign key to the value in the table that the values in the combo box came from.
 

Users who are viewing this thread

Back
Top Bottom