Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating Txt Box from Combo Selection

Status
Not open for further replies.

KerryL

Technical User
May 7, 2001
545
US
I know this question has already been asked, so I apologize for the duplication. But I tried using the answer from a previous post and couldn't get it to work.

I'm trying to populate a field called Region from a selection made in a combo box called County.

The County field combo box pulls its selections from a table called tblRegionList, which includes 3 columns: ID (the key field), Counties & Region. (The Region column contains the appropriate region for each county listed in the Counties column.)

When a user makes a selection from the County combo box, I would like the Region text box to be automatically updated with the correct region.

I created an "AfterUpdate" event procedure behind the County combo box, but I'm obviously missing something. Here's the event code:

Private Sub txtCounty_AfterUpdate()
Me!Region = Me!County.Column(2)
End Sub


When I update the County combo box, I receive the following run-time error:

Run-time error 438:
Object doesn't support this property or method.


Any help will be appreciated. Thank you.
KerryL
 
Hi Kerry!

You to explicitly indicate that you are asking for a control. Try this:

Me.Controls(Region) = Me.Controls(County).Column(2)

Note the 2 references the third column. It is best if you would give your controls less ambiguous names like txtRegion and cboCounty. Access gets confused easily! X-)

hth
Jeff Bridgham
bridgham@purdue.edu
 
I am slightly confused at the referencing of the fields also. The procedure runs on a field called txtCounty. Is this a text field or a combo box? Secondly you wrote:
Me!Region = Me!County.Column(2)
Should this not be:
Me!Region = Me!txtCounty.Column(2)



James Goodman
j.goodman00@btinternet.com
 
Apparently I'm confused on what I'm to reference in my code. The two fields I'm referring to are labeled as follows:

County Combo Box:
NAME = cboCounty
SOURCE = County

Region Text Box:
NAME = txtRegion
SOURCE = Region

I assume that in my case I should be referring to the two fields (in my AfterUpdate code) with the NAME text?

I often get confused on the difference between NAME, SOURCE, and in the case of combo boxes, ROW SOURCE. If someone can put this into better perspective for me I'd certainly appreciate it.

Thank you all for your help,
Kerry
 
Hi!

Lonnie has your answer!
:)

Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top