adding value from a combo box to a table

  • Thread starter Thread starter Arvin Meyer
  • Start date Start date
A

Arvin Meyer

You can insert the value into the table, or, if the subform is bound to the
table, simply read the combo box columns into the form's textboxes. The
example assumes that the combo is also on the subform, if it isn't, you'll
need to adjust the syntax (aircode):

Sub MyCombo_AfterUpdate()
Me.ControlName1 = Me.MyCombo.Column(0)
Me.ControlName2 = Me.MyCombo.Column(1)
Me.ControlName3 = Me.MyCombo.Column(2)
End Sub

As you can see, the column index is zero based. If the combo is NOT on the
subform, the code will be something like:

Me!NameOFSubformControl.Form!ControlName2 = Me.MyCombo.Column(1)
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Dave said:
Hi

I am trying to add the contents of a combo box to a table that is linked to
a subform. I feel that this should be soooo simple but still cant seem to do
it! :( I have a button that I was adding the code to.
If all the contents are to be added I suspect the easiest way would be to
set the control source to a foreign key that links the subform table to the
table from which the combo box is derived.

Your post does not make clear where the combo box is, on a main form or in
the sub form.
 
Hi

I am trying to add the contents of a combo box to a table that is linked to
a subform. I feel that this should be soooo simple but still cant seem to do
it! :( I have a button that I was adding the code to.

I am using Access 2000, with a combo box called cmboParts and a table called
tblParts_Ordered.

I have tried things involving

dim db as database
dim rs as recordset
etc but when ever I use the dim statements the whole procedure stops doing
anything, dont get compiler errors, runtime errors, msgBox doesn't work etc
which is stopping me from debugging. Its all very confusing :(

Can anyone help?

Thanks

Dave
 
Back
Top