change access from from "unbound" to "bound"

Aiysha
Aiysha used Ask the Experts™
on
I have a simple table in access database.
All I wan is to make one text box populated using drop down. For example.

My table
ID           County no                 County Name
1               1                                 area 1
2              2                                  area 2

My Form

County no                         "DROP DOWN"
Count Name                     "TEXT BOX 1"


I want text box to be filled out when I select the number in drop down.

Thank you much in advance for all your help.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
first set the Column Count property of the combo box to 3

Column Count  3


in the afterUpdate Event of the combo box, place this code

me.[TEXT BOX 1]= me.[DROP DOWN].column(2)



.[TEXT BOX 1] is assumed to be the name of the text box and
[DROP DOWN] is assumed to be the name of the combo box

if those are not true, change them accordingly

.

Author

Commented:
Rey,
Thank you for your response. I get the error with the pop up window when I make the suggested changes and run my form

"Microsoft Access cannot find the object "me."

Please help
Top Expert 2016

Commented:
where did you place the codes?

post them here...
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Distinguished Expert 2017
Commented:
There is no reason to store the country name but there are reasons for displaying both the country number and the name.  A simple, no code solution is to concatenate the country number and name in the query used as the combo's RowSource.

Select ID, [country no] & " - " & [country name] As CountryName From Your table
Order By [country no] & " - " & [country name];

Or, If you prefer country name first order then:
Select ID, [country name] & " - " & [country no] As CountryName From Your table
Order By [country name] & " - " & [country no];

I've attached a database with a sample that explains three methods of populating form fields from lookup values and when you should choose each technique.
FillFormFields130127.zip

Author

Commented:
PatHartman,

I really appreciate details in he dataset you uploaded. I am really new to access though a very old VBA programmer in excel.

Using responses on this question I have setup the form in attached database. However the operator field still does not get populated. Further problem is there are repeated operators and if I use distinct query then I lost connection with County combo box..any suggestions please?
TEXAS_LD---Copy.zip
Top Expert 2016

Commented:
test this

post back your comments
TEXAS_LD---revised.zip

Author

Commented:
thank you so much. I got that working now I am trying to fill out the textboxes and below is the code the does not work

Me.combo_operator = ""
Me.combo_operator.RowSource = "SELECT DISTINCT Permits.[Operator Name]" _
                            & " FROM Permits" _
                            & " WHERE(Permits.County) = '" & Me.Combo_county & "'"

-->    Me.Txt_District.Text = "SELECT Permits.District FROM Permits WHERE(Permits.County) ='" & Me.Combo_county & "'"
Top Expert 2016
Commented:
try this


Private Sub Combo_county_AfterUpdate()
Me.combo_operator = ""
Me.combo_operator.RowSource = "SELECT DISTINCT Permits.[Operator Name]" _
                            & " FROM Permits" _
                            & " WHERE(Permits.County) = '" & Me.Combo_county & "'"



Me.Txt_District = DLookup("District", "Permits", "County = '" & Me.Combo_county & "'")
End Sub

Author

Commented:
Very related to what I have been doing Rey can you please also show me how to fill list box with few fields from table and is exporting the list box into excel a completely different module?

thank you,
Aiysha.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial