Coding Afterupdate of Combobox to modify data shown in Textbox

P

Pluggie

Hi,

Probably the most asked question around on this forum... but hey... there
are no stupid questions... only stupid answers...

I have a continuous form.
On this form is a combobox.
Below the combobox is a textbox.

The Control Source of the Combobox is the numeric field "Status" of Table A.
The Row Source of the Combobox refers to the Autonumeric ID-field of Table B.
The Control Source of the Textbox is the Name-field of Table B.

By selecting a value in the combobox (so from ID-Field of Table B) I
submit/modify a value in the Status-Field of Table A.

Now... I want to use the Textfield to display the Name (from Table B), that
corresponds with the "new" value stored in the Satus-Field of Table A

Both the combobox and the textfield are boud (dunno if that is correct).
I think I need to add an After Update Event to my Combobox, but I am not
sure about the code.

Can anyone help me out?
 
D

Douglas J. Steele

Private Sub MyCombobox_AfterUpdate()

Me!MyTextbox = Me!MyCombobox.Column(1)

End Sub

That assumes that you want the value from the second column of the combo box
named MyCombobox put into the text box named MyTextbox (the Column
collection starts numbering at 0)
 
P

Pluggie

Hi Douglas,

Thank you, it works partially...
I needed to remove the Control Source of the Textbox before your code worked.
Now it displays the correct information.

But I also said I had a continuous form.
So it changes the information in the textboxes of all records displayed in
the form, in stead of just the one I modified with my combo.

How do you tackle this?
 
D

Douglas J. Steele

What was the control source of the text box? By removing it, you've made the
text box unbound, and an unbound text box will always display the same value
for each occurrance.
 
P

Pluggie

In my first message I wrote:
"The Control Source of the Textbox is the Name-field of Table B."
But your code does not work if I leave the textbox bound.
I do not have code in the textbox yet... maybe it should have something to
make it work?
 
D

Douglas J. Steele

The ControlSource must be a field that's in the RecordSource of the form.
You cannot point to a specific table if that table isn't part of the
RecordSource.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top