I need to send an email based upon query results via vba or macro. Here is the steps taken:
1) user clicks a button
2) I need a query ran with the following syntax:
select HighAlert from Orders where (order = 123456)
3) I need to cycle through those results (seperate order lines) and if HighAlert ever equals 1, then I need to send an email to one of our managers notifying him of the alert.
My vba is not up to par, but here is how I would do it in vbscript:
strSendEmail = "No"
dbc = database connection properties
set rs = Server.CreateObject ("adodb.Recordset")
ssql = "SELECT HighAlert FROM Orders WHERE (order = 123456)
rs.Open ssql, dbc, adOpenForwardOnly, adLockReadOnly
do while not rs.eof
if rs("HighAlertPart") = 1 then
strSendEmail = "Yes"
end if
rs.moveNext
Loop
rs.close
set rs=nothing
dbc.close
set dbc=nothing
if strSendEmail = "Yes" then
code to send email
end if
So, can someone help me achieve this goal by clicking an access button?
1) user clicks a button
2) I need a query ran with the following syntax:
select HighAlert from Orders where (order = 123456)
3) I need to cycle through those results (seperate order lines) and if HighAlert ever equals 1, then I need to send an email to one of our managers notifying him of the alert.
My vba is not up to par, but here is how I would do it in vbscript:
strSendEmail = "No"
dbc = database connection properties
set rs = Server.CreateObject ("adodb.Recordset")
ssql = "SELECT HighAlert FROM Orders WHERE (order = 123456)
rs.Open ssql, dbc, adOpenForwardOnly, adLockReadOnly
do while not rs.eof
if rs("HighAlertPart") = 1 then
strSendEmail = "Yes"
end if
rs.moveNext
Loop
rs.close
set rs=nothing
dbc.close
set dbc=nothing
if strSendEmail = "Yes" then
code to send email
end if
So, can someone help me achieve this goal by clicking an access button?