Closing Error message box programatically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Can someone help me....
I'm trying to find a way to close/supress error dialog box programatically...

I'm not able to suppress the message with
DoCmd.SetWarnings False
.....
DoCmd.SetWarnings True
because the error comes from ActiveX control.

then I tried to use FindWindow and PostMessage API function, but as the
dialog box is modal dialog, the code doesn't work.
Private Sub SetRTFFont(ByRef objRichCtrl As CustomControl)
If Me.LCID = 1041 Then
objRichCtrl.Object.Enabled = True
objRichCtrl.Object.SelStart = 0
objRichCtrl.Object.SelLength = 65000
objRichCtrl.Object.SelFontName = "MS Mincho"
objRichCtrl.Object.SelFontSize = 11
End If
Dim lhandle As Long
lhandle = FindWindow(0&, "RTF2")
Do While lhandle <> 0
lhandle = PostMessage(lhandle, WM_CLOSE, 0&, 0&)
lhandle = FindWindow(0&, "RTF2")
Loop
End Sub

Error handling also doesn't work
On Error GoTo Err_Check
....
Exit_CheckExit:
Exit Sub

Exit_Check:
Err.Clear
Resume Next

Regards,
Chris
 
What is the error that's arising? Closing the box programmatically isn't
nearly as desirable as not having it appear in the first place!

If you're determined to just close it, though, you should be able to adapt
the code in my May, 2005 "Access Answers" column in Pinnacle Publication's
"Smart Access". You can download the column (and sample database) for free
at http://www.accessmvp.com/DJSteele/SmartAccess.html
 
Hi Doug,

Thank you for the reply.
I'm using Lebans Rich Text ActiveX Control (RTF2) and I have my data with
font type MS PMincho with the size of 10. I want to have my data to be
displayed in MS Mincho and with font size of 11 instead on my report . So I
called these series of codes

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
....
objRichCtrl.Object.Enabled = True
objRichCtrl.Object.SelStart = 0
objRichCtrl.Object.SelLength = 65000
objRichCtrl.Object.SelFontName = "MS Mincho"
objRichCtrl.Object.SelFontSize = 11

and it seems that the call to SelFontName and SelFontSize generates the
error message "The property is read only". Nevertheless if I keep on closing
the error message, the font size and the font type is changed on the report
which is good enough for me. The font type and size of the data in the RTF2
control doesn't change though.

For that reason I tried to close the error dialog box programatically. Do
you have any idea how to prevent the problem? Thanks in advance.

Best Regards,
Chris
 
You'd need to track the error to whichever line of code is generating it,
and see about putting error handling in that routine.
 
Back
Top