Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2002

    Unanswered: Allow bypass key question

    I have used the following code to disable the "allow bypass key" on a few occasions and it works perfectly. Now I am trying to do the same on a new database and I cannot get it to work. I think I am failing to press some functionkey or other to activate the Module. Am I correct?

    Public Sub setallowbypasskey(bBypasss As Boolean)
    Dim dbs As Database, prp As Property, bBypass As Boolean
    Const conPropNotFoundError = 3270
    'Occurs if the property doesn't exist
    Const strKey = "AllowBypassKey"
    'Our property name
    Set dbs = CurrentDb
    'Set object to the current database
    On Error GoTo SetAllowBypassKeyErr
    'Specify error handler
    If bBypass = False Then
    dbs.Properties(strKey) = False 'Set AllowBypassKey to False
    dbs.Properties(strKey) = True 'Set AllowBypassKey to True (default)
    End If
    SetAllowBypassKeyExit: Exit Sub
    If Err = conPropNotFoundError Then ' Property doesn't exist yet
    If bBypass = False Then ' Create the property

    Set prp = dbs.CreateProperty(strKey, dbBoolean, False)
    Set prp = dbs.CreateProperty(strKey, dbBoolean, True)
    End If
    dbs.Properties.Append prp ' Add it to the collection
    Resume SetAllowBypassKeyExit
    End If
    End Sub

    The following is another Module "EnableControlModule" and both of these are used in working batabases in Access 97.

    Help much appreciated

  2. #2
    Join Date
    Jun 2002

    The second Module

    This is the second Module (Perhaps unrelated)

    Function EnableControls(strWhichSection As String, intState As Integer) As Integer

    ' Enable or disable controls in specified section of form.

    Dim frm As Form
    Dim ctl As Control
    Dim intX As Integer, intSelectedSection As Integer

    ' Use active form. If no form is active, exit
    ' function without displaying error message.
    On Error Resume Next
    Set frm = Screen.ActiveForm
    If Err Then
    EnableControls = False
    On Error GoTo 0
    Exit Function
    End If

    ' Define valid values for strWhichSection.
    Select Case UCase$(strWhichSection)
    Case "FORM HEADER"
    intSelectedSection = 1
    Case "PAGE HEADER"
    intSelectedSection = 3
    Case "DETAIL"
    intSelectedSection = 0
    Case "PAGE FOOTER"
    intSelectedSection = 4
    Case "FORM FOOTER"
    intSelectedSection = 2
    Case Else
    MsgBox "Invalid argument", , "EnableControls"
    EnableControls = False
    Exit Function
    End Select

    ' Set intState for all controls in specified section.
    For intX = 0 To frm.Count - 1
    Set ctl = frm(intX)
    If ctl.Section = intSelectedSection Then
    On Error Resume Next
    ctl.Enabled = intState
    On Error GoTo 0
    End If
    Next intX

    EnableControls = True

    End Function

  3. #3
    Join Date
    Feb 2002
    Have you confirmed that the subroutine is being called ? Have you tried debugging the code and stepping through ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts