View Full Version : entry made easy


kfboren
08-03-2001, 12:03 PM
I would like to be able to have a table that lists part numbers and descriptions. In a form I would like to enter the part number and have the description automaticlly entered.

JGillespie
08-03-2001, 03:10 PM
Use DLookUp function in the AfterUpdate event of the ProductCode field to set the value of the ProductDescription field.

kfboren
08-06-2001, 04:46 AM
Thank you for the help. I have tried several ways with the DLookup. Would you be so kind as to show me an example?

Pat Hartman
08-06-2001, 05:09 AM
I prefer to do this with a query utilizing a join. Take a look at the Orders database order entry form. When you choose a customer from the combobox, the BillTo and ShipTo addresses populate automatically. The BillTo address fields populate because they are bound to the form's recordsource via a join (this techinque is referred to as auto-lookup since you don't have to do anything. Access fills the fields on the form as soon as it knows what the key value is) and the ShipTo fields are populated with code in the AfterUpdate event of the combobox with data from the combobox query.

[This message has been edited by Pat Hartman (edited 08-06-2001).]

kfboren
08-06-2001, 10:41 AM
Pat I tried looking at the Orders database entry form. Mine does not have any combo box for the customer. Therefore I am still unable to complete this task. Please advise further.

kfboren
09-03-2001, 10:55 AM
I could use some help with the autolookup query. Any tips or tricks.

jwindon
09-03-2001, 12:28 PM
I have a little time on my hands...Let me try to show you what Pat is saying to do.

Create a form based off of the table that stores your part number descriptions. Put all the fields on your form you need to show. i.e. part description.

Show your toolbox and find the button that says "combobox". Drag it over and put it on the form. A wizard will start. You want to select Option #3 "Find records that match my selection". Your combo can be based off of any table or query that stores the Unique value to identify your partno. Based on what you have said thus far, I'm guessing you have it in the same table as the form you just built. You should be sure to include the PartNo as one of the fields you want in your combobox.

When you are finished, goto form view and use your combo. When you select the part no from this list, the fields below should reflect the description related to that part no. You can also begin to type in the part no and access will fill it out as you type.

This automation allows you to store much more information. Dlookup is used for display only. Say if you wanted to show a piece of information from another table not used in your form or combo.

If you still want to use it, it goes basically like this.

Unbound textbox is:

=Dlookup("NameOfFieldInTableYouNeed","NameOfTableYouNeedInfoFrom","[FieldNameThatMatchesForm]=Forms![FormNameYouAreOn]![FieldNameThatMatchesTable]")

Laocon
09-03-2001, 01:47 PM
Couldn't you just have a combo with two columns listing part no. and description?

Pat Hartman
09-03-2001, 04:00 PM
Include the description field in the query that you use to populate the form.

Select O.CustomerId, O.PartId, P.Description
From OrderTable As O Inner Join PartTable on O.PartId = P.PartId;

Then just make sure the bound control that displays description is set to Enabled = No and Locked = Yes so that the description cannot be accidentally updated from this form.

When you type a PartId or pick one from a combo box, the description will automatically fill in. You don't need to do anything.

kfboren
09-04-2001, 06:09 AM
Hey I got the results that I wanted on the form however the description does not post on the table. Any suggestions??

Pat Hartman
09-04-2001, 06:19 AM
The description is NOT supposed to be saved to the table. Just the PartId is saved. Any time you need to see the description, include the join to the part table to bring it into the query.