P
Pete
I'm new to this and my opportunity is -
I have a form wherein the StockID field is linked to a table as a lookup so
the stockID can be selected from a drop down list (combo box) . What I want
to do is once the StockID is selected, upon exit - have 4 other fields auto
filled.
With the below code -
Option Compare Database
Private Sub StockID_Exit(Cancel As Integer)
Dim varProductName, ProductDescription, UofM, TempCtrl As Variant
varProductName = DLookup("ProductName", "tblProductList", "StockID =
[StockID]")
varProductDescription = DLookup("ProductDescription", "tblProductList",
"StockID = [StockID]")
varUofM = DLookup("UofM", "tblProductList", "StockID =[StockID]")
varTempCtrl = DLookup("TempCtrl", "tblProductList", "StockID
=[StockID]")
If (Not IsNull(varProductName)) Then Me![ProductName] = varProductName
If (Not IsNull(varProductDescription)) Then Me![ProductDescription] =
varProductDescription
If (Not IsNull(varUofM)) Then Me![UofM] = varUofM
If (Not IsNull(varTempCtrl)) Then Me![TempCtrl] = varTempCtrl
End Sub
I get the auto fill - but it does not fill based on StockID - The fields are
being filled with the same information regardless of the StockID selected.
What do I need to do to have the fields filled based on the StockID
selected.
Thanks
Pete
I have a form wherein the StockID field is linked to a table as a lookup so
the stockID can be selected from a drop down list (combo box) . What I want
to do is once the StockID is selected, upon exit - have 4 other fields auto
filled.
With the below code -
Option Compare Database
Private Sub StockID_Exit(Cancel As Integer)
Dim varProductName, ProductDescription, UofM, TempCtrl As Variant
varProductName = DLookup("ProductName", "tblProductList", "StockID =
[StockID]")
varProductDescription = DLookup("ProductDescription", "tblProductList",
"StockID = [StockID]")
varUofM = DLookup("UofM", "tblProductList", "StockID =[StockID]")
varTempCtrl = DLookup("TempCtrl", "tblProductList", "StockID
=[StockID]")
If (Not IsNull(varProductName)) Then Me![ProductName] = varProductName
If (Not IsNull(varProductDescription)) Then Me![ProductDescription] =
varProductDescription
If (Not IsNull(varUofM)) Then Me![UofM] = varUofM
If (Not IsNull(varTempCtrl)) Then Me![TempCtrl] = varTempCtrl
End Sub
I get the auto fill - but it does not fill based on StockID - The fields are
being filled with the same information regardless of the StockID selected.
What do I need to do to have the fields filled based on the StockID
selected.
Thanks
Pete