Good Afternoon!
I am having problems running this code more than once. It will send an email the first time, but then hangs on concurrent tries. Any help would be greatly appreciated!
K
I am having problems running this code more than once. It will send an email the first time, but then hangs on concurrent tries. Any help would be greatly appreciated!
K
Code:
Private Sub Command84_Click()
Dim mySql As String, rs As New ADODB.Recordset, rs1 As New ADODB.Recordset
Dim mySql1 As String, mySql2 As String, mySql3 As String
Dim cn As New ADODB.Connection
Set cn = CurrentProject.Connection
Dim info As Variant
Dim ApprovalName As String
Dim login As String
Dim Linker As String
Dim Response As String
Dim varEmail As Variant
Dim varEmail1 As Variant
Dim intRecordCount As Integer
Dim counter As Integer
Dim username As String
Dim counter2
mySql1 = "SELECT Email FROM Users"
rs.Open mySql1, cn, adOpenStatic, adLockBatchOptimistic
counter = 0
varEmail = ""
Do Until rs.EOF
varEmail1 = rs(0)
If varEmail1 <> "" Then
varEmail = varEmail1 & ";" & varEmail
Else: End If
rs.MoveNext
counter = counter + 1
Loop
login = NetUserID()
mySql2 = "SELECT FullName FROM USERS Where UserName = " & Chr(34) & login & Chr(34) & ""
rs1.Open mySql2, cn, adOpenStatic, adLockBatchOptimistic
ApprovalName = rs1(0)
info = "A Approval Request has been submitted by " & ApprovalName & " Regarding Epic Procedure Number " & Me.TMID & " &" _
& "Please review within in the Procedure Tracking database." & Chr(13) & "MEMO: " & Me.MemoField1 & ""
Response = MsgBox("Do you want to Finalize the Approval Record?" & Chr(13) & Chr(13) & "This will send notification emails!", vbOKCancel)
If Response = vbOK Then
Linker = Me.ApprovalMasterNum
mySql = "Update Approval_Table Set InReviewFlag = True WHERE ApprovalMasterNum =" & Linker & ""
cn.Execute mySql
DoCmd.SendObject , , , varEmail, , , "Approval Request", info, False
Else: Exit Sub
End If
cn.Close
DoCmd.Close