Results 1 to 6 of 6
  1. #1
    Join Date
    May 2006
    Posts
    386

    Unanswered: Can anyone please help. I get this error " Sub or Function Not defined" when I try to

    Can anyone please help? When I double click on a text box in whose Double Click event I have written the code to disable the bypass key, I get this error "Sub or Function Not defined" and the first line as shown below is in yellow colour and it breaks on Setproperties. I have another db with the same functions and it runs without any problem.

    Below is the code: and

    Private Sub bDisableBypassKey_DblClick(Cancel As Integer)
    '***************** Code Start ***************
    'Assign this to the OnClick event of a command button (or double-click event
    'of a label or graphic) named "bDisableBypassKey"

    On Error GoTo Err_bDisableBypassKey_Click
    'This ensures the user is the programmer needing to disable the Bypass Key
    Dim strInput As String
    Dim strMsg As String
    Beep
    strMsg = "CAUTION!!! You are entering a danger zone! Are you Sure you want to Do that? It can endanger your porgram" & vbCrLf & vbLf & _
    "If you are still willing to take the riks, then enter your question."
    strInput = InputBox(Prompt:=strMsg, Title:="Disable Bypass Key Password")
    If strInput = "284absolute" Then
    SetProperties "AllowBypassKey", dbBoolean, True
    Beep


    Else
    Beep
    SetProperties "AllowBypassKey", dbBoolean, False

    Exit Sub
    End If
    Exit_bDisableBypassKey_Click:
    Exit Sub
    Err_bDisableBypassKey_Click:
    MsgBox "bDisableBypassKey_Click", Err.Number, Err.Description
    Resume Exit_bDisableBypassKey_Click
    End Sub


    any help and advice would be highly appreciated.
    Last edited by Emal; 06-22-07 at 12:33.
    Emi-UK
    Love begets Love, Help Begets Help

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Where is the function you are calling? I assume you are trying to use code similar to this. Have you imported the mod into this dB?
    Me.Geek = True

  3. #3
    Join Date
    May 2006
    Posts
    386
    Thanks for the reply. what do you mean by " where is the function you are calling? Yes, i m actually using this code. and this code works with my other db but not with the one with which i have problem with.
    Emi-UK
    Love begets Love, Help Begets Help

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    What he means is do you have a module, in your current db, with the function SetProperties in it?
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    May 2006
    Posts
    386
    hi Misslingling,
    Yes, there are couple of modules but i think the most relevant one to this code is this one:
    Option Compare Database

    Function DisableShiftKeyBypass(FileName As String, Allow As Boolean) As Boolean
    On Error GoTo Err_DisableShiftKeyBypass

    'The next time the database is opened after this function has been Run
    'the autoexec macro will not be bypassed, even if the shift key is pressed.

    On Error GoTo errDisableShift

    Dim wksp As DAO.Workspace
    Dim dbs As DAO.Database
    Dim Prop As DAO.Property
    Const conPropNotFound = 3270

    Set wksp = DBEngine.Workspaces(0)
    Set dbs = wksp.OpenDatabase(FileName)

    Dim Properties_Count As Integer
    Dim Found_It As Boolean
    Properties_Count = 0
    Found_It = False

    Do
    If dbs.Properties(Properties_Count).Name = "AllowByPassKey" Then
    Found_It = True
    End If
    Properties_Count = Properties_Count + 1

    Loop While Properties_Count < dbs.Properties.Count And Found_It = False

    If Found_It = False Then
    ' AllowByPassKey is not a property of this database. Add it.
    Set Prop = dbs.CreateProperty("AllowByPassKey", dbBoolean, False, True)
    dbs.Properties.Append Prop
    End If

    dbs.Properties("AllowBypassKey") = Not dbs.Properties("AllowByPassKey")
    MsgBox ("Bypass Property is set to " & dbs.Properties("AllowBypassKey").Value)
    DisableShiftKeyBypass = Allow

    exitDisableShift:
    Exit Function

    errDisableShift:
    'The AllowBypassKey property is a user-defined Property of the
    'database that must be created before it can be set. This error
    'code will execute the first time this function is run in a Database
    Select Case Err
    Case conPropNotFound
    Set Prop = dbs.CreateProperty("AllowByPassKey", dbBoolean, False, True)
    dbs.Properties.Append Prop
    Resume Next
    Case Else
    'Function DisableShiftKeyBypass did not complete successfully
    MsgBox Error
    DisableShiftKeyBypass = False
    Resume exitDisableShift
    End Select

    Exit_DisableShiftKeyBypass:
    Exit Function

    Err_DisableShiftKeyBypass:
    MsgBox Err.Description
    Resume Exit_DisableShiftKeyBypass
    End Function
    Emi-UK
    Love begets Love, Help Begets Help

  6. #6
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    You misunderstand, Emal! You have to have a module in your database with the function named SetProperties defined in it! Go into the code window behind any form, goto Edit -- Find. Under Search select Current Project then in the search box enter Function SetProperties. If this doesn't take you to the function, it means it's not in your current database!

    If that's the case, you'll need to open one of your databases where the code does work, and repeat the steps above to locate Function SetProperties. Once you do that, close Find, then close the module the function is in. You should now be back in the Objects Dialog box, and the module you just exited should be hilighted.

    Goto File -- Export and export the module to the database you're trying to fix.

    Open the new databse, and see if the code now works.

    Good Luck!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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