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

Setting a delay time in Macro before Quit command 1

Status
Not open for further replies.

qjade

Programmer
Jun 7, 2004
42
US
Hello friends,
I currently have a macro created that run 7 separate reports and sending them out via outlook. The problem I have is that it is only two out and then exit abruptly as though the report generation process has taken too long and the Quit function in my macro has caught up. Please let me know if there is a simple way to implement a pause/delay before in between my report execution and the "Quit" macro command. Thanks in advance.
 
here is what I do in some cases similar to urs..

Usage:
Utilities.DelayTime 3


I have the following code in my Utilities Module.

Public Function DelayTime(PauseTime As Double)
'sometimes used to slow the program down and allow for screen updating or
'other processes to catch up
Dim start
'PauseTime = 4 ' Set duration.
start = Timer ' Set start time.
Do While Timer < start + PauseTime
DoEvents ' Yield to other processes.
Loop
End Function


Steve Medvid
&quot;IT Consultant & Web Master&quot;

Chester County, PA Residents
Please Show Your Support...
 
Hello smedvid,
Please excuse me for my lack of VB knowledge but when I used your suggestion above I ran into a problem. Please tell me if I am doing this right.
First, I created a new module with your code above and saved it as 'Utilities'. Then I selected it in between my reports generation in my macro to give it a delay of DelayTime(5).
The problem I have is that it is not recognizing the Usage: Utilities.DelayTime 3.
Please let me know what I am doing wrong. Thanks again for your valuable time and input.
 
For the Macro try --
Run Code
DelayTime (3)


For some reason, it does not appear to like the fully qualified ModuleName.FunctionName syntax. Appears to work fine just listing function name and parameter using the Run Code option.


Steve Medvid
&quot;IT Consultant & Web Master&quot;

Chester County, PA Residents
Please Show Your Support...
 
Sorry for taking such a long time to post my status on this problem but I still have the same problem. It has become a little evident to me now that I need some sort of a sleep function in my module instead of a DelayTime(), so I think! I am hoping to find a way to slow down my macro so that all preceding macros can catch up an run themselves to completion. The suggested DelayTime() is wonderful; however, it is giving back control to the operating systems and not giving consideration to the remaining 6 macros that I have running there after. Please let me know if I am completely off base with this. Thanks a million again.
 
qjade,

Try something like this.
This will prevent Access from closing!
This code was found here at TekTips,
don't recall the orginal poster!

Create a new form.
Name it: frmDontQuit

Paste this code
Code:
Option Compare Database
Option Explicit

Public AllowClose As Boolean

Private Sub cmdClose_Click()
   AllowClose = True
   DoCmd.Close acForm, Me.Name
End Sub

Private Sub Form_Load()
    AllowClose = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Cancel = Not AllowClose
End Sub


Now on the last Report that is sent
Add this code...

Code:
AllowClose = True

Now in your macro...
Add a command to open the form 1st, hidden
then process the reports.


Not tested, just a suggestion...


Hope this helps.
Carl


AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Thank you all for your help. I eventually found the problem to my dB. It was due to the body of my SendObject being too long. Just another prime example of how incredible Microsoft is to still dominate our PCs when all they put out is garbage with million of bugs. Below is the answer to my problem from a close friend. Hope this will help someone else from not wasting as much time as I have.

Here is the fix for the issue you are having with the sendall macro failing:



There is a bug that may cause the sendObject method to fail when there are over 70 characters in the message.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top