Access 2010
Access 2003
Seminars
Tips & Tricks
Access Forum
Course Index Insider Circle
 
Tutorials   News   Tips   Forums   Help   Logon   Order  
 
     
 
Tips & Tricks

New Tips Added Weekly!
Click here to get on our Mailing List

   

  Access   Excel   Word   Windows   FrontPage   Hardware   Misc

 

Microsoft Access DLOOKUP Function

Looking Up a Value from a Table or Query

Q: I have a service call form where I track service calls for each customer. I can pick a customer from a combo box, like you covered in your relational combo box tutorial. Now, however, I'd like to know how to automatically set the address of the service call to the customer's current address - but I need to be able to change it if necessary, so I can't just show the customer's address. Help!

A: In order to do this, you're going to need a little bit of VBA programming. Now, if you've never done any VBA programming before, I strongly recommend you start by taking my Access 301 tutorial. I cover all of the basics (no pun intended) of VBA programming with Access.

Now, there is a special function called DLOOKUP (short for Domain Lookup) which lets you look up a value in a table or query. For your example, you need to look up the Address, City, and State fields (and ZIP code if you have it) from your customer table where the CustomerID is the same as the CustomerID on your service form - or in this case, the value in your CustomerCombo box since you're picking from a list.

Here's how the DLOOKUP function works:

=DLOOKUP (Field, Domain, Criteria)

The Field is simply any field you want to return the value of: Address, City, State, ZIP, etc. The Domain is any table or query where your data resides. The Criteria allows you to tell DLOOKUP which record to return.

For example, if you want to get the last name of the customer whos ID is 5, then you'd say:

=DLOOKUP ("LastName", "CustomerT", "CustomerID=5")

Since you're working with a service call form and the value of the CustomerID is in a combo box called CustomerCombo, you'd use the following line to get the selected customer's Address:

=DLOOKUP ("Address", "CustomerT", "CustomerID=" & CustomerCombo)

When you put this in the AfterUpdate event for the CustomerCombo, the Address field can be automatically populated on your form. Then, just add in DLOOKUP statements for any other fields like City or State that you might need.

Here's a screen shot from one of my tutorials. The address fields are automatically populated when the customer is changed using the combo box.

 

Here is a FREE VIDEO TUTORIAL that will walk you through this topic in detail.

I teach the concepts in this free mini tutorial in my Access 302 course. These are full courses - over 60 minutes in length each. I spend a lot more time going over how to do this, in addition to lots more tips and tricks.

 

You may want to read these articles from the 599CD News:

 

 
Learn
 
Microsoft Access
Microsoft Excel
Microsoft Word
Microsoft Windows
Microsoft PowerPoint
Adobe Photoshop
Visual Basic
Active Server Pages
Online Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
Lost Password
WalkThru Tutorials
Free Upgrades
Insider Circle
Info
 
Latest News
New Releases
User Forums
Tips & Tricks
Search Our Site
Waiting List
Production Schedule
Help
 
Live Chat
Customer Support
Troubleshooting
FAQs
TechHelp
Consulting Services
About Us
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Order
 
Video Tutorials
Handbooks
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Live Chat
General Contact Info
Support Policy
Contact Form
Email Us
Mailing Address
Phone Number
Fax Number
Course Survey
Try Us
 
Free Lessons
Online Theater
Mailing List
Course Indexes:   Microsoft Access   Microsoft Excel   Microsoft Word   Microsoft PowerPoint   Visual Basic (VB)   Photoshop   Active Server Pages (ASP)  
Keyword Search Cloud:   What's This?   courses   microsoft access tutorials   vlookup   access   cartesian   excel   dlookup   vba   attendance   access 2007   sql   windows 7   combo box   pivot table   visual basic   test   iif   word   calendar   query   conditional formatting   pivot tables   photoshop   hlookup   access 101   excel 202   excel 2007   student attendance   update query   my account   word 2007   append query   quickbooks   queries   dsum   reports   powerpoint   if   microsoft access   dmax   mail merge   relationships   ms access   access 2010   vb   dcount   subforms   excel 2003   handbooks   html   599cd   combobox   if function   security   microsoft word   after update  
Copyright 2012 by 599CD.com, All Rights Reserved