Auto-populate

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

Guest

I have a continous subform where I collect the ChemicalName,
InternalCode,SupplierCode, AmountUsed,etc. The ChemicalName and Codes are
stored in a tblCompChems but there isn't always an InternalCode or
SupplierCode.
On my subform when ChemicalName is selected from the dropdown I want
InternalCode and SupplierCode to be filled in automatically if they exist for
that Chemical in tblCompChems. I think DLookup is the way to go but I'm not
sure how to handle when a code doesn't exist. The Codes are text fields.
Thanks for the help.
 
J,

Did you try it with DLookup? I expect this would still work fine in the
cases where there are no codes... the textboxes on the subform will just
be left blank.

There are 2 other ways to do it as well. One is to base the subform on
a query that includes the tblCompChems table, joined on the ChemicalName
field from both tables. That way, you can have the InternalCode and
SupplierCode available in the query, and hence can be directly
represented on the subform... as soon as the ChemicalName is entered,
the Codes will be automatically displayed. The other approach is to use
a multi-column combobox for the entry of the ChemicalName, so that the
InternalCode and SuplierCode fields are included in the Row Source of
the combobox. Then, you can enter the control source of the code
controls on the subform like this...
=[ChemicalName].[Column](1)
=[ChemicalName].[Column](2)
 
Back
Top