' ***************************
' Typical Use
' Numerical values. Replace "number" with the number to use.
variable = DFirst("[FieldName]", "TableName", "[Criteria] = number")
' Strings.
' Numerical values. Replace "string" with the string to use.
variable = DFirst("[FieldName]", "TableName", "[Criteria]= 'string'")
' Dates. Replace "date" with the string to use.
variable = DFirst("[FieldName]", "TableName", "[Criteria]= #date#")
' ***************************
' ***************************
' Referring to a control on a form
' Numerical values
variable = DFirst("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)
' Strings
variable = DFirst("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")
' Dates
variable = DFirst("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
' ***************************
' ***************************
' Combinations
' Multiple types of criteria
variable = DFirst("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
& " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
& " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")
' Use two fields from a single record.
variable = DFirst("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")
' Expressions
variable = DFirst("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")
' Control Structures
variable = DFirst("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
' ***************************