Procedure launches sooner than I think it should

J

John

I have code that sends an email at the end of a sub
routine (in form "A") to notify user when complete. The
code launches a form (form "B") in another database and
runs a command button on that remote form. The code later
runs a procedure called Dedupe (which is a simple
recordset looping thru a table) that resides in same
database as form "A". These two tasks take at least 40
minutes to run. The problem is that the program launches
at approx 4:30AM, the email is sent at same time, but the
actual procedures may be done at say 5:15AM. Why does the
email launch before the other code is finished???

Here is trimmed down version of the code. The form where
this code resides is opened in dialog mode. Using Access
97.
'---------------------------------------
Sub test()
Dim strDB As String
Dim varFileName As String
Dim fs

Set fs = Application.FileSearch

With fs
.LookIn = "M:\ndm_files\"
.filename = "*.dat"
If .Execute > 0 Then
strDB = "j:\extracts\c2data.mdb"
Set appAccess = _
CreateObject("Access.Application.8")
appAccess.OpenCurrentDatabase strDB, True
appAccess.DoCmd.OpenForm "MainForm" 'aka form "B"
appAccess.Forms!Mainform.CommandButton_Click
appAccess.Application.Quit

Dedupe 'calls procedure that dedupes data in
'table within database
End If
End With

'Procedure below sends email message from Lotus Notes
NotesMail "Import Complete", "(e-mail address removed)", _
"Import Complete"
End Sub
'----------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top