StarScream
Technical User
DLookUp Not Populating Field - Why ?
I have a form ("Task Info"
that populates all the fields in one of my tables. However, one of these fields is optional ("Personnel ID"
. However, if the user selects a person, then I want this bit of code to retrieve that person's email address ("Email"
from a second table ("Personnel"
.
"Personnel ID" is the field that links to the both tables, but I want it to be optional. If I link my form to these two tables (using an INNER JOIN clause), then the user HAS to select a person (ie, must enter someone in "Personnel ID" field) in order for the form to save any of the data entered as a new record. I just want to make it an optional thing, so that if they do select a person, then the code will populate the variable AO_Email. Does this make sense ?
PJ
I have a form ("Task Info"
Code:
Dim AO_Email As Variant
AO_Email = DLookup("[Personnel][Email]", "[Personnel]", "[Personnel][Personnel_ID] = " & Forms!Task_Info!Personnel_ID)
Set objOutlookRecip = .Recipients.Add(AO_Email)
objOutlookRecip.Type = olTo
"Personnel ID" is the field that links to the both tables, but I want it to be optional. If I link my form to these two tables (using an INNER JOIN clause), then the user HAS to select a person (ie, must enter someone in "Personnel ID" field) in order for the form to save any of the data entered as a new record. I just want to make it an optional thing, so that if they do select a person, then the code will populate the variable AO_Email. Does this make sense ?
PJ