Link to home
Start Free TrialLog in
Avatar of deer777
deer777Flag for United States of America

asked on

Need vba code to send email and screenshot to individual if form textbox exceeds certain amount.

Need vba code to send email and screenshot to individual if form textbox exceeds certain amount.
Avatar of PatHartman
PatHartman
Flag of United States of America image

Isn't someone looking at the screen?  Why would you need to email someone else?  When would you want this to happen?  After they changed the value but Before they saved the record or After?  If Before, what if they don't actually save?  Please tell us what you are trying to accomplish.
Avatar of deer777

ASKER

Currently I am summing the value of another field in this calculated field.  

If the calculated field exceeds 3 then the manager wants to know immediately to perform certain actions.
Agree with Pat.

Some ways to avoid this:
1. Create a combobox with only valid entries
2. Set the "Field Size" property in the table to be the max text length
...ect

What you are asking is fairly involved for something that can be avoided...

send email and screenshot to individual
"THE" individual making the mistake?
Or
to "Some other" individual...?


Instead of allowing them to make a mistake,  and then sending an email,
...why not prevent the mistake from occurring in the first place...?

JeffCoachman
Avatar of deer777

ASKER

Email will be sent to another individual.  

I asked the same question but was told to just send an email immediately.

Do not have to have a screenshot just thought it would be more informative.
Avatar of deer777

ASKER

The email should be sent after the record was saved.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can use the code I have posted for my crashreporter on my blog:
TheSmileyCoder: Crash Reporter
Its original intent is to screenshot the the application whenever a crash occurs, and email that info to the developer, but you should be able to modify it to screenshot your form, and email that instead.
deer777,

Oh, ...and for my proposal you will have to set a reference to the Outlook VBA library in your code.
Avatar of deer777

ASKER

Jeff, not having any luck in the code working.  I am probably doing something wrong.  The textbox on the form is calculated based on the sum of another textbox on the continuous form.  I have the code running in the after update of the total textbox which holds the sum.  I updated my references to include Outlook.  Even tried putting the code in the form current but had no luck there.  Just not receiving email at all.
IMHO, ...doing calculations in the query might be a better option.

I cant speculate on why this is not working for you without a sample of the db you are using...

But first things first, ...does my sample perform as needed?
The code needs to be in the Form's AfterUpdate event as Jeff coded it.  Put a breakpoint in the code so you can step through it to see where it is going astray.
Glad I could help