Klassic
Klassic

Reputation: 13

Updating Fields in a Table with Values from Query

I'm struggling to understand why my event code for updating a Microsoft Access form field is only half working.

I have a query, we'll call DataQuery, that selects 3 column values from what we'll call Table1 that looks like the following:

**Part**       **Description**       **Revision**
10-123             Descrip1             A
10-342             Descrip2             D
10-232             Descrip3             E

I have another table where I'd like to assign the values from description and revision to fields in another table, we'll call Table2, based on picking a value in a combo box.

For instance:

We select a value of 10-342 in our combo box, then the values "Descrip2" and "D" get assigned to fields in Table2.

I can get this to work for whatever column I have in position one, but not position two.

My small vba code:

Private Sub ComboBox_AfterUpdate()

    Me.DescriptionField_Table2 = Me.ComboBox.Column(1)
    Me.RevisionField_Table2 = Me.ComboBox.Column(2)
    Me.Requery

End Sub

Where "ComboBox" row source is DataQuery mentioned previously.

As stated, "Me.DescriptionField_Table2 = Me.ComboBox.Column(1)" works as intended, but the second line seems to be getting ignored. I feel like I'm missing something super simple here, but I'm can't figure it out.

Upvotes: 0

Views: 224

Answers (1)

Klassic
Klassic

Reputation: 13

I knew this was something simple...

Gustav, in the comments, answered my issue:

Set property ColumnCount of the combobox to 3.

Upvotes: 1

Related Questions