Full Version: Auto Fill Field on Form
UtterAccess Forums > Microsoft® Access > Access Forms
skyzulu
Been trying to auto fill my OrderDetails Forms' UnitPrice by just entering data ini ChemicalID field, pls anybody help me.
GroverParkGeorge
Here is a simpler way.
hange the row source for the ChemicalID from
"SELECT tblChemID.ChemicalID FROM tblChemID;"
to
"SELECT tblChemID.ChemicalID, tblChemID.UnitPrice FROM tblChemID;"
This will make the Unit Price available in the combo box for each Chemical.
Then change the column count for ChemicalID to 2.
Make the column widths for ChemicalID "1;0" to hide the UnitPrice column, but leave it available to your VBA.
Change the AfterUpdate event to:
CODE
Private Sub ChemicalID_AfterUpdate()
    Me!UnitPrice = Me.ChemicalID.Column(1)
Exit_ProductID_AfterUpdate:
    Exit Sub
End Sub

Columns in a combo or list box are numbered left to right, with 0 being the first column, 1 the second and so on.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.