Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

General: DLookup Usage Samples

Author(s)
Dev Ashish

    Note that the same logic applies to most Domain Aggregate Functions (DMax, DMin etc.)

Normal usage

For numerical values:
        DLookup("FieldName" , "TableName" , "Criteria = n")

For strings: (note the apostrophe before and after the value)
        DLookup("FieldName" , "TableName" , "Criteria= 'string'")

For dates:
        DLookup("FieldName" , "TableName" , "Criteria= #date#")

 

Refering to a form control

For numerical values:
        DLookup("FieldName", "TableName", "Criteria = " & forms!FormName!ControlName)

For strings: (note the apostrophe before and after the value)
        DLookup("FieldName", "TableName", "Criteria = '" & forms!FormName!ControlName & "'")

dates:
        DLookup("FieldName", "TableName", "Criteria = #" & forms!FormName!ControlName & "#")

 

Mix-n-Match

   DLookup("FieldName", "TableName", "Criteria1 = " & Forms!FormName!Control1  _
             & " AND Criteria2 = '" & Forms!FormName!Control2 & "'" _
            & " AND Criteria3 =#" & Forms!FormName!Control3 & "#")

© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer