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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code Help...

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
The following code is to open form "Customers to Notify by Email (Deleted Orders)" and if field "Customer Refernce Number" contains a value, the automerge file in Word is opened. This then repeats in order to print the suitable letter. After this an update query is run to tell the database that the people have been notified. The problem is that the only way I could find to stop the module form going too quickly and the query deleting the items in the form, before the letters have printed was to add the message boxes where the module doesn't continue until the user clicks OK. Is there a function that will stop the macro from continuing until Word has finished its work. I've tried lots of things, but they all allow the macro to continue in the background, which obviously defeats the object!

Option Compare Database

'------------------------------------------------------------
' Email_Customer_Notification
'
'------------------------------------------------------------
Function Email_Customer_Notification()
Dim retval

On Error GoTo Email_Customer_Notification_Err

DoCmd.OpenForm "Customers to Notify by E-mail (Deleted Orders)", acNormal, "", "", , acNormal
If (Eval("[Forms]![Customers to Notify by E-mail (Deleted Orders)]![CustomerName/Title] Is Not Null")) Then
retval = Shell("winword.exe C:\CustomerLetter(DeletedOrder)-E-mail.dot", 1)
End If
DoCmd.Close acForm, "Customers to Notify by E-mail (Deleted Orders)"
MsgBox "Please click OK when messages have been sent"
DoCmd.OpenForm "Customers to Notify by E-mail (Successful Orders)", acNormal, "", "", , acNormal
If (Eval("[Forms]![Customers to Notify by E-mail (Successful Orders)]![CustomerName/Title] Is Not Null")) Then
retval = Shell("winword.exe C:\CustomerLetter(SuccessfulOrder)-E-mail.dot", 1)
End If
DoCmd.Close acForm, "Customers to Notify by E-mail (Successful Orders)"
MsgBox "Click OK when messages have been sent"
DoCmd.OpenQuery "Update Cutomers who have been Post Notified", acNormal, acEdit


Email_Customer_Notification_Exit:
Exit Function

Email_Customer_Notification_Err:
MsgBox Error$
Resume Email_Customer_Notification_Exit

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top