0
votes

Sorry in advance for the long description, but it seemed like the prudent course of action.

I am having a problem getting a combo box to correctly populate a text field in a subform.

Based on surfing the web and some helpful guidance on adding VBA to forms earlier this week here is what I tried.

I have created a table tblPgo showing several probabilities of a project proceeding and a corresponding descriptions.

enter image description here

I have a second table tblDetails containing information about the items we are selling.

These two tables interact in a subform tblDetals subform.

I added a combo box cmbPgoValue to the subform. The combo box gets its data from tblPgo

Control Source is Pgo

Row Source is SELECT [tblPgo].[PgoID], [tblPgo].[Pgo], [tblPgo].[PgoDescription] FROM tblPgo ORDER BY [Pgo];

The Row Source syntax was created by the combo box wizard.

In the subform, I created an unbound text box called Pgo Description to receive the PgoDecription text corresponding to the selected Pgo value from the combo box.

cmbPgoValue has the following After Update Event code

Private Sub cmbPgoValue_AfterUpdate()

Me.PgoDescription = Me.cmbPgoValue.Column(2)

End Sub

When I use the combo box to select a Pgo value, the correct Pgo Description populates the current record and the record below it. When I try completing the incorrectly populated record, I get an error about duplicating indexes, etc.

I've tried bounding the text box, but it does not seem to help.

Thanks in advance.

enter image description here

1
There is a field named Pgo in tblDetails? Advise not to use same exact field name in multiple tables.June7

1 Answers

1
votes

That is to be expected with UNBOUND textbox. There is only the one Description textbox so all records will show the same info. Should not be duplicating this info into tblDetails. Instead of VBA, just have expression in textbox ControlSource:

=cmbPgoValue.Column(2)