Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email after NEW record is entered

Status
Not open for further replies.

Fireman1143

IS-IT--Management
Mar 5, 2002
51
US
In my application I would like to have an email sent to two supervisors alerting them that a NEW Service Request has been entered. I have the email part working correctly but can not figure where to place the Event. Everywhere I place it it gets sent BEFORE the record is saved and some of the information is not included. I tried OnChange, OnUpdate etc. I was going to try OnClose but this would send it everytime the record is viewed, not just when a new record is created. Any ideas?

Fireman1143
 
You should place the code to run under a command button.

Also...you may need to refresh the forms content before executing the code.

Try
me.refresh

or

docmd.domenuitem acformbar, acrecordsmenu, 5, ,acmenuver70

Hopefully this is some help for you.

Regards,

Peter

Remember- It's nice to be important,
but it's important to be nice :)
 
how are you saving the records?

from a bound form?
from unbound form?
directly entered into table?
...?
 
the event that fires after a record is saved is the after update of the form, I think
 
Peter,

Thanks, I'll try that later today.

Fireman1143
 
Crowley16

This is a regular input form showing the Date, Request Number, Company, Contact etc. After the form is entered, I want to send an emai for which I have already got the fields to work in. It takes the Company, Scheduled Date, and who it is Assigned to and writes the email as " New Service Ticket #[Req_TicketNumber]for [Req_Company] has been scheduled for [Req_ScheduledDate] and assigned to [Req_AssignedTo].

This form is opened by a button on the main form of the Company, so some information i.e.the Ticket Number is autonumber and the and the Company Name and Assigned To are eneterd from the main form. I placed this Event in the first filed - Entered By - and had it as OnChange. This triggered the email and sent it as I wanted, but since I had not entered the Req_ScheduledDate, no date was shown on the email. That is why I am looking to trigger it after the record has saved so all information is available. I also do not want this to trigger if an user is reviewing the record and then leaves it.

Thanks,
Fireman1143
 
in that case, you should put something like

if me.dirty then
'send e-mail...
endif

in the onExit event of the form
 
And what about the AfterInsert event procedure ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
That's right PHV!
Fireman1143, The BeforeInsert & AfterInsert events, pertain to new records. BeforeInsert is before the record has been saved to the table, the AfterInsert, is after it's been saved. Similiar to Before/AfterUpdate, but during insertion of a new record.
So, as PHV said, AfterInsert, is the appropriate event.
I would include Me.Refresh, just before sending also.
Good Luck!
 
Thanks dboulos and PHV,

The AfterInsert was the place to put it. Works like a charm!

Fireman1143
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top