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

"The code running has been interrupted."

Status
Not open for further replies.

Bresart

Programmer
Feb 14, 2007
314
ES
Hi, i have a form for printing a report that includes an index, for that first i export the report and after i delete the exported file. The code is:

DoCmd.OutputTo acOutputReport, "repGeneral_pager", acFormatSNP, CurrentProject.Path & "\temp1.snp", False

DeleteFile ("" & CurrentProject.Path & "\temp1.snp")


The time between exporting and deleting is about 1 to 2 min, in that time the hourglass pointer is shown.

If i press the Ctrl+Pause keys several times, a window with title Microsoft Visual Basic appears, saying The code running has been interrupted.

Is there any way of handling that avoids the window popup?

Thanks in advance.
 
If you want to stop the code then why execute it?

ck1999
 
Thanks ck1999 JoeAtWork. I don't want to stop the code, i do want to avoid errors for third users. The status bar informs about pressing Ctrl+Pause for cancelling the page formatting of a report before opening it.
 
try this before your docmd line

dim temp as variant
Temp = SysCmd(acSysCmdClearStatus)

This might remove the status bar info.

I think you have two options
1. remove the status bar from saying press ctl+pause
2. capture the keystroke to prevent code from stopping

ck1999
 
Thanks ck1999. The control with the focus when this happens is a command button, i have added in the KeyDown event of the command button the code

If KeyCode = vbKeyControl Then
KeyCode = 0
End If


but the control key keeps being enabled.

Is there another way of handling the keys Ctrl+Pause?
 
You can respond to specific keystrokes in the form's KeyDown, KeyPress, and KeyUp events. You can prevent a control from receiving keystrokes you've responded to, and prevent the keyboard events from occurring for the control, by setting the KeyCode argument to 0 for both the KeyDown and KeyUp events, and setting the KeyAscii argument to 0 for the KeyPress event. You must set all three arguments to 0 if you don't want the control to receive the keystrokes.

url:
ck1999
 
Thanks ck1999.

I have included:

Private Sub Comand46_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyControl Then
KeyCode = 0
End If
End Sub

Private Sub Comand46_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyControl Then
KeyCode = 0
End If
End Sub

Private Sub Comand46_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyControl Then
KeyAscii = 0
End If
End Sub


but the Ctrl key keeps enabled. Is there anything wrong or omitted?
 
I'd use this in the KeyDown and KeyUp event procedures:
If (Shift And acCtrlMask) > 0 Then
KeyCode = 0
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Have you set the form's KeyPreview property to Yes?

Max Hugen
Australia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top