Good afternoon, folks. I have been trying to figure this out for the last couple of days and to no avail, maybe someone here can straighten me out. To start I have a function, which collects e-mail addresses from a table and sends a message to everyone who has a certain checkbox checked. Here is the function:
Function EMailUsers()
Dim rs As Object
Dim strSQL As String
Dim strERecipient As String
Set rs = CreateObject("ADODB.Recordset"
strSQL = MystrSQL
rs.Open strSQL, CurrentProject.Connection
If Not rs.EOF Then
rs.MoveFirst
Do Until rs.EOF
strERecipient = strERecipient & rs(0) & ";"
rs.MoveNext
Loop
If strERecipient <> "" Then
strERecipient = Left(strERecipient, Len(strERecipient) - 1)
End If
DoCmd.SendObject , , , strERecipient, , , "ECN " & Forms!frmECNMasterData200!!ECNNumber & " is ready for Assembly/Purchasing Approval.", , False 'formats and sends email to Authorized users
End If
End Function
Sense I have a dozen or so cmdButtons I figure this would be the way to go, and just call it in the sub to run it. MystrSQL has thre different variations, depending on which checkbox if checked on the main form. Here is the sub:
Dim MystrSQL As String
If Me.Check208 = True Or Me.Check210 = True Then
MystrSQL = "SELECT [EMailAddress] FROM tblAuthorizedUsers WHERE [ApdAsy] = True"
Call EMailUsers
End If
When I attempt to run it all I get is:
-2147217908 Command text is not set to command object.
Anyone one have any suggestions? Thank you in advance to anyone redering assistance.
Function EMailUsers()
Dim rs As Object
Dim strSQL As String
Dim strERecipient As String
Set rs = CreateObject("ADODB.Recordset"
strSQL = MystrSQL
rs.Open strSQL, CurrentProject.Connection
If Not rs.EOF Then
rs.MoveFirst
Do Until rs.EOF
strERecipient = strERecipient & rs(0) & ";"
rs.MoveNext
Loop
If strERecipient <> "" Then
strERecipient = Left(strERecipient, Len(strERecipient) - 1)
End If
DoCmd.SendObject , , , strERecipient, , , "ECN " & Forms!frmECNMasterData200!!ECNNumber & " is ready for Assembly/Purchasing Approval.", , False 'formats and sends email to Authorized users
End If
End Function
Sense I have a dozen or so cmdButtons I figure this would be the way to go, and just call it in the sub to run it. MystrSQL has thre different variations, depending on which checkbox if checked on the main form. Here is the sub:
Dim MystrSQL As String
If Me.Check208 = True Or Me.Check210 = True Then
MystrSQL = "SELECT [EMailAddress] FROM tblAuthorizedUsers WHERE [ApdAsy] = True"
Call EMailUsers
End If
When I attempt to run it all I get is:
-2147217908 Command text is not set to command object.
Anyone one have any suggestions? Thank you in advance to anyone redering assistance.