Can anyone spot the datatype error in the DLookup statement (see screenshot)? "AppID" and "RosID" are numeric table autonumbers. "Attending" is a Yes/No field in table "Appendages". "RetYear" is a text field in table "Appendages". "glbRetreatYear" is a string variable.
As an aside, what's the correct syntax to replace the cumbersome use of, for example, Me.RecordsetClone![Email] when attempting to simplify code appearance using "With". VBA complained when I tried .![Email].
The whole Sub:
Code:
Private Sub Gather_EMail_Addresses(Mode As Variant)
Dim strtemp As String
Dim strToClipBoard As String
Dim LineCnt As Integer
Me.EM_Addr_Cmd.Visible = True 'Reveal the primary command button
'Me.cmdShowAll.Enabled = True 'Re-enable when choice buttons executed.
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
' We need to gather the e-mail addresses of the current Roster and display them in such away that
' they can easily be copied and subsequently be pasted into an addressee pane. When Mode equals
' "AO" (Attendees Only), then the gathering is limited accordingly.
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
strToClipBoard = ""
LineCnt = 0
If Me.RecordsetClone.RecordCount > 0 Then
With Me.RecordsetClone
.MoveFirst
Do While .EOF = False
If IsNull(Mode) Or DLookup("Attending", "Appendages", "AppID = " & Me.RecordsetClone![RosID] & " AND RetYear = " & gblRetreatYear) = True Then
If Len(Trim(Me.RecordsetClone![Email])) > 0 Then
strtemp = Chr(34) & Me.RecordsetClone![LastName] & Chr(34)
strtemp = strtemp & "<" & RTrim(Me.RecordsetClone![Email]) & ">," & vbNewLine
LineCnt = LineCnt + 1
strToClipBoard = strToClipBoard & strtemp
End If
End If
.MoveNext
Loop
strToClipBoard = Left(strToClipBoard, Len(strToClipBoard) - 1)
End With
ClipBoard_SetText (strToClipBoard)
Else
MsgBox "There no individuals in this group."
End If
Me.RecordSource = "QRoster"
Me.FilterOn = True
Me.EM_Addr_Cmd.SetFocus
Me.EM_Addr_Cmd.Caption = "DONE (" & LineCnt & " Addresses)"
End Sub