Auto value

M

melbourno

I have a form that has multiple fields.

I can’t seem to figure out how to auto pick a value based on another
field.

For example: my form has city and populations number. I would like to
have in the population field the value of it based on the city I pick
from a CamboBox
 
M

melbourno

Assuming you have your combobox set up with two columns, the city field and
the population field, (the city field appearing on the left, the population
field being on the right) this code will populate the population textbox,
called txtPopulation in this example.

Private Sub cboCityCombobox_AfterUpdate()
 Me.txtPopulation = Me.cboCityCombobox.Column(1)
End Sub

Just substitute your actual textbox and combobox name.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted viahttp://www.accessmonster.com

Thank you for your reply. Below is my code for it:

Private Sub Site_City_AfterUpdate()
Me.Text36 = Me.Site_City.Column(1)
End Sub

It's still not auto populate the population in Text36 where it should
show on the form. One more thing I didn't mention, after fill and
submitting the form it will save Text36 in another table with header
"Effected Users"
 
J

John W. Vinson

Thank you for your reply. Below is my code for it:

Private Sub Site_City_AfterUpdate()
Me.Text36 = Me.Site_City.Column(1)
End Sub

It's still not auto populate the population in Text36 where it should
show on the form. One more thing I didn't mention, after fill and
submitting the form it will save Text36 in another table with header
"Effected Users"

The Column() property is zero based, so (1) would be the second column in the
query. Does the query in fact have the desired value in the second field? And
is the ColumnCount big enough to include the field?

Two problems that I can see: if you can look up the value from the SiteCity
table, then you should probably NOT store it in any field; just look it up
instead. And the proper word in this context is "Affected" not "Effected".
 

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

Similar Threads


Top