auto update on form

  • Thread starter Thread starter Tracey
  • Start date Start date
T

Tracey

Is there any way to chose a value from a combo box in a
form and have it automatically update the next field in
the form. I have a field for Employee number and when i
enter the number i want it to automatically enter in the
employee name in the next field. Help...i'm new at this.
 
Tracey said:
Is there any way to chose a value from a combo box in a
form and have it automatically update the next field in
the form. I have a field for Employee number and when i
enter the number i want it to automatically enter in the
employee name in the next field. Help...i'm new at this.

If you enter the employee number in the record, there is no need to
store the name as well. You should change your data structure to reflect
this. Do a search on 'normalization' for further reading.
 
This is from some MS article... It gives the complete method using the
Northwind db as an example...

Damon
************************************
The following example uses the sample database Northwind.mdb
(NWIND.MDB in
earlier versions). The first combo box lists the available product
categories, and the second combo box lists the available products for
the
category selected in the first combo box:

1. Open the sample database Northwind.mdb (or NWIND.MDB in 1.x and
2.0).

2. Create the following new query based on the Products table, and
then
save the query as Category Combo Query:

Query: Category Combo Query
---------------------------------------------------------
Table: Products
Type: Select Query
Field: ProductID (or Product ID in 1.x and 2.0)
Sort: Ascending
Show: Yes
Field: ProductName (or Product Name in 1.x and 2.0)
Table: Products
Show: Yes
Field: CategoryID (or Category ID in 1.x and 2.0)
Show: No
Criteria: Forms![Categories and Products]![Categories]

3. Create a new form not based on any table or query with the
following
combo boxes, and save the form as Categories And Products.

Combo Box 1
-------------------------------
Name: Categories
RowSourceType: Table/Query
RowSource: Categories
ColumnCount: 2
ColumnWidths: 0;1
BoundColumn: 1
AfterUpdate: Refresh Products

NOTE: The Name property is called the ControlName property in
Microsoft Access 1.x.

Combo Box 2
-----------------------------------
Name: Products
RowSourceType: Table/Query
RowSource: Category Combo Query
ColumnCount: 2
ColumnWidth: 0;1
BoundColumn: 1

NOTE: The BoundColumn property of the first combo box should not be
set
to the field named in the Criteria row of the above query;
otherwise,
the second combo box displays only the first record.

4. Create the following new macro and save it as Refresh Products:

Macro Name Actions
---------------------------
Refresh Products Requery

Action Arguments
----------------
Control Name: Products

5. View the Categories And Products form in Form view. When you select
a
category in the first combo box, the second combo box is updated to
list only the available products for the selected category.

Notes
-----

In the above example, the second combo box is filled with the results
of
the Category Combo Query query. This query finds all the products that
have a CategoryID that matches the category selected in the first
combo
box.

Whenever a category is selected in the first combo box, the
AfterUpdate
property runs the Refresh Products macro, which forces the second
combo
box to run the Category Combo Query query again. This refreshes the
list
of available products in the second combo box. Without this macro, you
would have to force the second combo box to refresh itself by pressing
the F9 key.

REFERENCES:
===========

For more information about synchronizing combo boxes, search for
"synchronize," and then "synchronizing combo boxes" using the
Microsoft
Access Help Index.

Additional query words: listbox combobox link
======================================================================
Keywords : FmsCmbo kbusage
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbhowto
============================================================================
=
Copyright Microsoft Corporation 1997.
 
Tracey,

Not sure what you've got in mind, but it sounds like you could use one of
two techniques in a combo box 'AfterUpdate' method:

1) to call a 'Requery' method.

2) to set a field value using a 'DLookup("[Name]","Employee","Number=" &
Me!EmployeeNumber)' function call

If you look up these keywords in Help you'll see a couple of examples.
 
Back
Top