Filling Text Boxes from a Combo Box

G

Guest

I have two combo boxes that are based on queries. The queries are sorted by
school name for one box and school code for the other. Both combo boxes are
bound and data selected from one box will update the other. This process
works fine. There are four other text boxes that are updated by this query.

The problem I'm having is, some schools have identical names. As you type
the name in the combo box, the section of identical names will move to the
top. If I select say the third name in the group, all the boxes will update
correctly. However, if you change the name to another identical name, say
the fourth one in the group, the combo boxes will update correctly, but the
data in the text boxes will be for the first one in the group. Why is this
happening and how can I fix it?

Here is the code for one of the combos

Private Sub cboSCHOOL_NAME_AfterUpdate()

Me![SCHOOL_CODE].Value = cboSCHOOL_NAME.Column(1)
Me.[SNAME].Value = cboSCHOOL_NAME.Column(0)

Me.[LOW_INCOME].Value = cboSCHOOL_NAME.Column(4)
Me![LOW_PERF_20].Value = cboSCHOOL_NAME.Column(5)
Me![LOW_PERF_50].Value = cboSCHOOL_NAME.Column(6)
Me![RURAL_AREA].Value = cboSCHOOL_NAME.Column(7)
Me![EMRG_PERMIT].Value = cboSCHOOL_NAME.Column(8)
Me![COUNTY_NAME].Value = cboSCHOOL_NAME.Column(2)
Me![DISTRICT_NAME].Value = cboSCHOOL_NAME.Column(3)


Me.REFRESH
End Sub
 
G

Guest

Hi Jim,

When I do this, I don't use the after update event as you have done, I
simply have

=cboSCHOOL_NAME.Column(1)

as the Control Source for an unbound text box (in this instance, SCHOOL_CODE)

Hope this helps.

Damian.
 
G

Guest

Damian

Thanks for the response. This is an existing database that has been worked
on by several people over the years. I'm just one of many. Unfortunately,
I don't think I can do that in this case. The text boxes, as they are
currently configured, can be updated by either combo box. It's set up this
way to provide the user options regarding how they look up a school. If I
set up the control source in the text boxes to only one of the combo boxes
then the other combo box won't update the text boxes.

Damian S said:
Hi Jim,

When I do this, I don't use the after update event as you have done, I
simply have

=cboSCHOOL_NAME.Column(1)

as the Control Source for an unbound text box (in this instance, SCHOOL_CODE)

Hope this helps.

Damian.

jimphilly said:
I have two combo boxes that are based on queries. The queries are sorted by
school name for one box and school code for the other. Both combo boxes are
bound and data selected from one box will update the other. This process
works fine. There are four other text boxes that are updated by this query.

The problem I'm having is, some schools have identical names. As you type
the name in the combo box, the section of identical names will move to the
top. If I select say the third name in the group, all the boxes will update
correctly. However, if you change the name to another identical name, say
the fourth one in the group, the combo boxes will update correctly, but the
data in the text boxes will be for the first one in the group. Why is this
happening and how can I fix it?

Here is the code for one of the combos

Private Sub cboSCHOOL_NAME_AfterUpdate()

Me![SCHOOL_CODE].Value = cboSCHOOL_NAME.Column(1)
Me.[SNAME].Value = cboSCHOOL_NAME.Column(0)

Me.[LOW_INCOME].Value = cboSCHOOL_NAME.Column(4)
Me![LOW_PERF_20].Value = cboSCHOOL_NAME.Column(5)
Me![LOW_PERF_50].Value = cboSCHOOL_NAME.Column(6)
Me![RURAL_AREA].Value = cboSCHOOL_NAME.Column(7)
Me![EMRG_PERMIT].Value = cboSCHOOL_NAME.Column(8)
Me![COUNTY_NAME].Value = cboSCHOOL_NAME.Column(2)
Me![DISTRICT_NAME].Value = cboSCHOOL_NAME.Column(3)


Me.REFRESH
End Sub
 

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