Under the gun, HELP!!!

M

mr3316a

I am running Access 2007
I have some code that generates excel files based on parameters set in a
form, creates an e-mail in Outllook, and adds the files as attachments. Then
stars the next files an e-mail. When I run this in debug mode everything
works fine. After the looping is complete, the form closes and I have a bunch
of e-mails in Outlook waiting for me to click send on each.

When I run the same code NOT in debug mode, after the 1st e-mail I get a
run-time error 2046 " The command or action 'Output To' isn't available now".

If I comment the function where Outlook is called, the code runs fine. Is
there a way that I can programaticly stop the code after the 1st e-mail is
completed, and automaticly restart after I click the send e-mail button in
Outlook!
 
C

Clifford Bass via AccessMonster.com

Hi,

The simplest method would be to put up a message box in Access after it
passes control to Outlook. When done in Outlook go back to Access and click
OK to the message.

Alternatively you might add into you code one or more "DoEvents" to tell
Access to allow for other things to happen.

Or, if that does not help, you might call out to the Windows Sleep()
function. Place this at the top of your code window below any Option...
statements:

Public Declare Sub Sleep _
Lib "kernel32" _
(ByVal dwMilliseconds As Long)

Then in your code you can do something like this to sleep for say 2
seconds:

Sleep 2000

And finally, there are other methods of sending e-mails. You could use
the Microsoft CDO for Windows 2000 Library. See <
http://msdn.microsoft.com/en-us/library/ee663283(v=VS.85).aspx> for
information about that and maybe even some other options.

Clifford Bass
 
M

mr3316a

Thanks for the quick reply.
Will the kernel32 work with XP or is it just for 95,98, and NT?

Clifford said:
Hi,

The simplest method would be to put up a message box in Access after it
passes control to Outlook. When done in Outlook go back to Access and click
OK to the message.

Alternatively you might add into you code one or more "DoEvents" to tell
Access to allow for other things to happen.

Or, if that does not help, you might call out to the Windows Sleep()
function. Place this at the top of your code window below any Option...
statements:

Public Declare Sub Sleep _
Lib "kernel32" _
(ByVal dwMilliseconds As Long)

Then in your code you can do something like this to sleep for say 2
seconds:

Sleep 2000

And finally, there are other methods of sending e-mails. You could use
the Microsoft CDO for Windows 2000 Library. See <
http://msdn.microsoft.com/en-us/library/ee663283(v=VS.85).aspx> for
information about that and maybe even some other options.

Clifford Bass
I am running Access 2007
I have some code that generates excel files based on parameters set in a
[quoted text clipped - 10 lines]
completed, and automaticly restart after I click the send e-mail button in
Outlook!
 
M

Mark Andrews

If you are sending multiple emails you might want to look into an SMTP
component.
I use Ostrosoft's (however I use a older version, they changed it a bit in
this new version).
There are probably a dozen or so SMTP components out there in the market
(most are about $50)

Usually one dll and a few lines of code to send the email.

You could check out my donation software if you want to see it in action,
try sending email to 15 contacts as an example etc....

HTH,
Mark Andrews
RPT Software
http://www.rptsoftware.com
http://www.donationmanagementsoftware.com
 
C

Clifford Bass via AccessMonster.com

Hi,

To my knowledge, it should work up through the latest version of Windows.
While I do not know for sure as I am still using older Windows, I presume
there is also now a 64-bit version of the kernel dll.

Clifford Bass
Thanks for the quick reply.
Will the kernel32 work with XP or is it just for 95,98, and NT?
[quoted text clipped - 30 lines]
 

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