automatically populate a field in a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In an Access database, I want a user to type a value in field. Based on that
value, I want to populate a second field. The lookup data is in a table.
I am using Access 2000.
 
Hi, AP.

Be sure to search past postings first, especially when you suspect your
question is a typical one.

This can be accomplished by either 1) Basing your form on a multi-table
query, which contains the fields of interest; 2) Using the Column property of
a combo box.

For the latter, columns are labeled 0,1,2...etc. If the Bound Column of the
combo box is the first one (usually the Primary Key), and you wish to display
the 3rd column in a textbox, set the latter's Control Source to:

=YourComboBoxName.Column(2)

HTH
Sprinks
 
Sprinks, thx for ur comments. Difficulty understanding the examples in help.
do u know where i can get more examples?
 
The sample Northwind database has many examples you can look at. It is now
under Help/Sample Databases. You can also get pretty good help in the VBA
window, to which you can get by either View, Code from Form design view,
entering or editing an event procedure, or by pressing <Ctrl-G> (Immediate
Window) from the database window.

Also, when entering code, Access supplies the relevant parameters of
functions and methods as you type, and you can highlight a keyword and press
<F1> to get context-sensitive help.

If you didn't follow my example, have you delved into Properties yet? Each
form control (textbox, combo box, etc.) and the form itself has a variety of
Properties that
you can set. Click View, Properties from the form design window.

The Control Source property is where the control gets its data, which might
be a fieldname, a calculation, or in your example, a call to the Column
method of the combobox.

If you're just starting with Access, I unfortunately can not recommend a
good text, but once you have some experience, I've found the Access 2000
Developer's Handbook by Getz, Litwin, et al. invaluable. You might search
this Newsgroup, however. Others have recommended texts.

Other than that, Allen Browne and Roger Carlson, frequent contributors to
this Newsgroup, have websites with useful code available.

I think the key to understanding Access VBA is to learn how the object
hierarchy--how everything is referred to--and what properties and methods
are. Once you understand that, it's easy to add the basic control
structures, which are similar to most programming languages. Another great
way to learn is to insert command buttons or combo boxes with the Wizard
enabled (View, Toolbox, toggle on the button with the wand and stars), and
then study the code the wizard creates.

Hope that helps. Good luck. Any other specific questions, post away!

Sprinks
 
Back
Top