Using dlookup to auto populate a form field?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CrazyAL
    New Member
    • Apr 2007
    • 2

    Using dlookup to auto populate a form field?

    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!
  • CrazyAL
    New Member
    • Apr 2007
    • 2

    #2
    Nevermid, I figured it out. I had a name wrong - user error. This is a great site BTW. :)

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by CrazyAL
      Nevermid, I figured it out. I had a name wrong - user error. This is a great site BTW. :)
      Yeah, we're pretty amazing. Solved that one for you without even trying. :D

      Seriously, it's good to see you've resolved your problem. Hope you'll stick around in case you can answer any others.

      Comment

      Working...