Autofill Form Fields

  • Thread starter Thread starter Erika
  • Start date Start date
E

Erika

I am using a form as a look up for people to be able to enter a product and
then have aisle, level, and position automatically fill in so people in the
warehouse can locate a specific product.

How do I set that up? I am finding a lot of information on event procedures
but I am not a strong Access user and I am unfamiliar with that.
 
The usual way to do a lookup for a specific record in a form is to use an
unbound combo box. In most cases, (using your example) a product will have a
code that is the primary key of the product table and it will have a
description understandable to humans. The combo box needs to have a query as
its row source that will present a list of products to the user. It needs
two columns - one for Access to be able to find the record (the primary key
field) and one for the human to read (the description field). It is a good
practice to show only the description field. The user doesn't need to see
the product code. So the query would look something like:

SELECT ProductID, ProductDescr FROM tblProduct ORDER BY ProductDescr;

Then set the combo's properties like this:

Bound Column = 1
Column Count = 2
Column Widths = 0";3" (the 0 hides the Id, the 3 can be whatever needed to
show the entire description)
Limit To List = Yes

Now when the user selects a product from the combo, you have to locate the
product's record and make it the current record. This you do in the combo's
After Update event. Here is sample code to do that:

Private Sub MyCombo_AfterUpdate()

With Me.RecordsetClone
.FindFirst "[ProductID] = " & Me.MyCombo
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With

This line assumes ProductID is a number field in the table:
.FindFirst "[ProductID] = " & Me.MyCombo
If it is a text field, the syntax is:
.FindFirst "[ProductID] = """ & Me.MyCombo & """"
 

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

Back
Top