I am working on a form to add entries into my assets table. I am trying to figure out how to make a purchase price field auto populate after entering model number into a combo box. There maybe a much simpler way to do this but here is what I have:
Private Sub Combo_Model_Exi t(Cancel As Integer)
Dim varPrice As Variant
varPrice = DLookup("Purcha sePrice", "tblModelIn fo", "ModelNumbe r = [combo_model]")
If (Not IsNull(varPrice )) Then Me![PurchasePrice] = varPrice
End Sub
I have all my models and prices in a seperate table called ModelInfo. The only two fields in that table are ModelNumber and PurchasePrice. It seems like there should be a way to do this with the combo box and not dlookup. My combo box currently has both colomus of the ModelInfo table (ModelNumber being the unique identifier). BTW this is the first thing I have tried to do in VB in about 4 years so please keep it kinda simple. Thanks!
Private Sub Combo_Model_Exi t(Cancel As Integer)
Dim varPrice As Variant
varPrice = DLookup("Purcha sePrice", "tblModelIn fo", "ModelNumbe r = [combo_model]")
If (Not IsNull(varPrice )) Then Me![PurchasePrice] = varPrice
End Sub
I have all my models and prices in a seperate table called ModelInfo. The only two fields in that table are ModelNumber and PurchasePrice. It seems like there should be a way to do this with the combo box and not dlookup. My combo box currently has both colomus of the ModelInfo table (ModelNumber being the unique identifier). BTW this is the first thing I have tried to do in VB in about 4 years so please keep it kinda simple. Thanks!
Comment