Error in using combo box field in text box

G

Guest

I am trying to display field values from a combo box in a text box. This is
what I have done so far based on prior postings on this subject:

In combo box row souce I select the fields for the combo box; Select SPid,
SPfirst, SPlast, SPspec from SP

Bound column = 0

In the AfterUpdate event I entered the following code:
Private Sub SpID_AfterUpdate()
Me.FirstName = Me.SpID.Column(1)
End Sub
FirstName is the name of my text box.

In the Control Source property in my textbox I entered: =me.SpID.column(1)

When I open my form and select an item in my combo box I get a runtime error
that says "Can't assign a value to this object." When I click on Debug it
references the line" Me.FirstName = Me.SpID.Column(1)".

Any ideas on what am I doing wrong? Any help would be appreciated.
 
M

Marshall Barton

ahearn said:
I am trying to display field values from a combo box in a text box. This is
what I have done so far based on prior postings on this subject:

In combo box row souce I select the fields for the combo box; Select SPid,
SPfirst, SPlast, SPspec from SP

Bound column = 0

In the AfterUpdate event I entered the following code:
Private Sub SpID_AfterUpdate()
Me.FirstName = Me.SpID.Column(1)
End Sub
FirstName is the name of my text box.

In the Control Source property in my textbox I entered: =me.SpID.column(1)

When I open my form and select an item in my combo box I get a runtime error
that says "Can't assign a value to this object." When I click on Debug it
references the line" Me.FirstName = Me.SpID.Column(1)".

Any ideas on what am I doing wrong? Any help would be appreciated.


You're trying to use two different methods to display the
fiest name in the text box. When you use a control source
expression in a text box, it automatically makes the text
box read only. Either get rid of the control source
expression or get rid of the AfterUpdate assignment
statement.

Note that I think it is highly unlikely that you want the
BoundColumn property to be 0. Set it to 1 instead.
 
G

Guest

Thanks for your response. I took out the AfterUpdate assignment and I no
longer get the error message. However, my text box just displays the #Name
error. What I am trying to do is when a user picks a specialist id # from a
combo box, the first and last name are to be displayed on the form, as well
as their medical speciality.

I followed the advice from a prior posting on this matter and obviously it
didn't work for me.
 
M

Marshall Barton

After checking more carefully, I see that you are trying to
use:
=Me.SpID.column(1)
when Me is only valid inside a VBA Class module (the form's
code). Get rid of it and just use:
=SpID.column(1)
 

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