473,320 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

I want to send an email using a macro but only once? Access 2010

Hi there.

I have a macro set up to send an email when a condition exists. The macro will send when the value in a field is equal or greater than 500,000, but I only want to send this email once. At the minute, everytime the field is updated, because its still over 500,000, the macro sends again. I have tried adding a stopMacro after the if statement but this doesn't appear to do anything?
Mar 24 '12 #1

✓ answered by ADezii

@Corwin Moyne
  1. Declare a Private, Form Level, Boolean Variable as such:
    Expand|Select|Wrap|Line Numbers
    1. Private blnEMailSent As Boolean
  2. Execute Code similar to the following:
    Expand|Select|Wrap|Line Numbers
    1. If Me![txtTest] > 500000 And Not blnEMailSent Then
    2.   blnEMailSent = True
    3.     MsgBox "Send E-Mail here"
    4. End If
  3. An E-Mail will only be set if the Value of Me![txtTest] > 500000 AND blnEMailSent = False
  4. By Default, blnEMailSent will be initialized to False, and if the Value is > 500000 it will then be Reset to True and another E-Mail will not be sent unless blnEMailSent is somehow again Reset to False.

4 2315
ADezii
8,834 Expert 8TB
@Corwin Moyne
  1. Declare a Private, Form Level, Boolean Variable as such:
    Expand|Select|Wrap|Line Numbers
    1. Private blnEMailSent As Boolean
  2. Execute Code similar to the following:
    Expand|Select|Wrap|Line Numbers
    1. If Me![txtTest] > 500000 And Not blnEMailSent Then
    2.   blnEMailSent = True
    3.     MsgBox "Send E-Mail here"
    4. End If
  3. An E-Mail will only be set if the Value of Me![txtTest] > 500000 AND blnEMailSent = False
  4. By Default, blnEMailSent will be initialized to False, and if the Value is > 500000 it will then be Reset to True and another E-Mail will not be sent unless blnEMailSent is somehow again Reset to False.
Mar 24 '12 #2
NeoPa
32,556 Expert Mod 16PB
Check the before status as well as the after status.

Only if the after status is > 500,000 and the before status not > 500,000 should you trigger the routine.
Mar 24 '12 #3
Thank you ADezii!!! I was looking for hours for this code!!
Mar 25 '12 #4
ADezii
8,834 Expert 8TB
You are quite welcome. Keep in mind that you can Reset the Value of the Variable at any time, and return to the Original State by executing:
Expand|Select|Wrap|Line Numbers
  1. blnEMailSent = False
Mar 25 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: aish | last post by:
I want to send email using sql stored procedure.my code is work fine in my local sqlserver account. when I use my online sql server it display this error. EXECUTE permission denied on object...
8
by: Nick Li | last post by:
Hi, I am trying to writing a c program to send email using system() function call on Unix(Sun Solaris). I tried the following: #include <stdio.h> #include <stdio.h> int main(void) {
11
by: Mohammed Abdel-Razzak | last post by:
dear sirs i want to send email using c# but i don`t want to use CDONTS or tell me how can i use it i don`t know any thing about CDONTS thanks
9
by: Bob Jones | last post by:
We have developed a commercial ASP.net application (personal nutrition management and tracking); we want to send smtp email from within it. For our development box, we use WinXP Pro, IIS 5.5,...
0
by: padmanabhanp | last post by:
Hai, How to send email using jsp
2
usafshah
by: usafshah | last post by:
How can i send email using php through SMTP server ?
0
by: thinkwebs | last post by:
hi guys Just i am trying to send email using syste.web.mail in ASP.Net just i have send mail successfully in the web but i can't send mail with attachment in the web. But my coding works properly...
14
by: Warren Tang | last post by:
Hi I am using the mail function to send a mail like this: $b = mail("my_real_email_address@gmail.com", "Hello from PHP", "Hi, finally sent an email successfully"); But it failed. Could you...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.