Форумы HiProg.com - MS ACCESS, VBA, VB

 

Ответить на сообщение

Вернуться к теме

Вы отвечаете на сообщение:

ник: Stanislav
Сейчас для примера создал пустую форму, разместил на ней кнопку и checkbox.


Option Compare Database
Option Explicit

Private Sub Command0_Click()
DoCmd.Close acForm, "Form1"
End Sub

Private Sub Form_Unload(Cancel As Integer)
If Me.Check1 = -1 Then
Cancel = True
End If
End Sub


Ставлю галку в checkbox. Если пытаюсь закрыть форму крестиком - она не закрывается, как и должно быть. Если пытаюсь закрыть кнопкой, выдает ошибку: runtime error 2501 the close action was cancelled.

Нашел в инете следующее:


In the sample application we use IsMemberOfSecurityGroups to set Cancel to True only if the user is not allowed access.

There is one somewhat unfortunate side-effect of setting Cancel to True: the calling routine will get a runtime error 2501 = The OpenForm action was canceled. We handle that with an error handler that ignores the error if it is number 2501:

1: Private Sub cmdForm2_Click()
2: On Error GoTo Error_Handler
3:
4: DoCmd.OpenForm "frmTest_NoAccess"
5:
6: Exit_Handler:
7: Exit Sub
8:
9: Error_Handler:
10: If Err.Number = 2501 Then
11: 'Error 2501 = The OpenForm action was canceled.
12: 'Not really an error. Just indicates we were unable to open the form, which is normal if we have insufficient rights.
13: Else
14: MsgBox Err.Description, vbCritical
15: End If
16: Resume Exit_Handler
17: End Sub


источник:http://www.accesssecurityblog.com/

В общем, никакая это не ошибка, надо ее обработать и не показывать.


Ваше имя:

Пароль:

Цитировать: [quote][/quote] Код: [code][/code]
Жирный: [b][/b] Наклонный: [i][/i]
URL: [url][/url] 

Сообщение:

 Размер файла не более 50 Кбт. Большие файлы можно размещать на www.slil.ru

Прикрепить:

 

Для вставки смайлов в текст щелкните по значку.