By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,097 Members | 1,170 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,097 IT Pros & Developers. It's quick & easy.

Using dlookup to auto populate a form field?

P: 2
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_Exit(Cancel As Integer)

Dim varPrice As Variant
varPrice = DLookup("PurchasePrice", "tblModelInfo", "ModelNumber = [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!
Apr 5 '07 #1
Share this Question
Share on Google+
2 Replies

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

Expert 5K+
P: 8,434
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.
Apr 6 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.