DeathTrap82
Registered User.
- Local time
- Today, 09:03
- Joined
- Jun 25, 2012
- Messages
- 10
I'm trying to write a DLookup (and DMax) using an array as one of the criteria (code snippet below). However, I'm not sure how to get it to work. I need it to only return the [PeriodStart] if the [TitleCode] is one of the numbers in the array titleCodeSearch. I had thought there was an "In" keyword, but I must be thinking of a different language.
Code:
Dim rID as Integer, startTime as Date, titleCodeSearch(1 To 7) As Variant
rID = r!DOMID
titleCodeSearch(1) = 1717
titleCodeSearch(2) = 1724
titleCodeSearch(3) = 1455
titleCodeSearch(4) = 1728
titleCodeSearch(5) = 1732
titleCodeSearch(6) = 3220
titleCodeSearch(7) = 3394
If DLookup("[OtherActionTaken]", "[Appointment]", "[DOMID] = " & rID & " And [OtherActionTaken] = 'APT'") = "APT" Then
startTime = DMax("[PeriodStart]", "[Appointment]", "[DOMID] = " & rID & " And [OtherActionTaken] = 'APT' And [TitleCode] In '" & titleCodeSearch & "'")
End If
If DLookup("[OtherActionTaken]", "[Appointment]", "[DOMID] = " & rID & " And [OtherActionTaken] = 'APPT'") = "APPT" Then
If startTime < DMax("[PeriodStart]", "[Appointment]", "[DOMID] = " & rID & " And [OtherActionTaken] = 'APPT' And [TitleCode] In '" & titleCodeSearch & "'") Then
startTime = DMax("[PeriodStart]", "[Appointment]", "[DOMID] = " & rID & " And [OtherActionTaken] = 'APPT' And [TitleCode] In '" & titleCodeSearch & "'")
End If
End If