AllowBreakIntoCode Property

Applies To   Database object.

Description

You can use the AllowBreakIntoCode property to specify whether or not the user can view Visual Basic code after a run-time error occurs in a module.

Setting

The AllowBreakIntoCode property uses the following settings.

Setting

Description

True (–1)

Enable the Debug button on the dialog box that appears when a run-time error occurs.

False (0)

Disable the Debug button.


The easiest way to set this property is by using the Allow Viewing Code After Error option in the Advanced section of the Startup dialog box, available by clicking Startup on the Tools menu. You can also set this property by using a macro or Visual Basic.

To set the AllowBreakIntoCode property by using a macro or Visual Basic, you must first either set the property in the Startup dialog box once or create the property by using the CreateProperty method and append it to the Properties collection of the Database object.

Remarks

You should make sure the AllowBreakIntoCode property is set to True when debugging an application.

If the AllowSpecialKeys property is set to True, you can still press CTRL+BREAK to pause execution of Visual Basic code, even if the AllowBreakIntoCode property is set to False.

This property's setting doesn't take effect until the next time the application database opens.

See Also   AllowSpecialKeys property, CreateProperty method ("DAO Language Reference"), Properties collection ("DAO Language Reference").

Example

The following example shows a procedure named SetStartupProperties that passes the name of the property to be set, its data type, and its desired setting. The general purpose procedure ChangeProperty attempts to set the startup property and, if the property isn't found, uses the CreateProperty method to append it to the Properties collection of the Database object. This is necessary because these properties don't appear in the Properties collection until they've been set or changed at least once.

Sub SetStartupProperties()
    ChangeProperty "StartupForm", dbText, "Customers"
    ChangeProperty "StartupShowDBWindow", dbBoolean, False
    ChangeProperty "StartupShowStatusBar", dbBoolean, False
    ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
    ChangeProperty "AllowFullMenus", dbBoolean, True
    ChangeProperty "AllowBreakIntoCode", dbBoolean, False
    ChangeProperty "AllowSpecialKeys", dbBoolean, True
    ChangeProperty "AllowBypassKey", dbBoolean, True
End Sub

Function ChangeProperty(strPropName As String, varPropType As Variant, _
        varPropValue As Variant) As Integer
    Dim dbs As Database, prp As Property
    Const conPropNotFoundError = 3270

    Set dbs = CurrentDb
    On Error GoTo Change_Err
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True

Change_Bye:
    Exit Function

Change_Err:
    If Err = conPropNotFoundError Then            ' Property not found.
        Set prp = dbs.CreateProperty(strPropName, _
            varPropType, varPropValue)
        dbs.Properties.Append prp
        Resume Next
    Else
        ' Unknown error.
        ChangeProperty = False
        Resume Change_Bye
    End If
End Function