Solved

Disable shift key in .adp

Posted on 2004-09-08
13
857 Views
Last Modified: 2008-02-01
I picked up the following code from another post, "Database" is not recognized in the Dim statement.  I'm using Access XP and i a BIG hurry.  I need the answer within the hour.  Is there something else I need to use in an adp?  Please help.

Function BackDoor(rbFlag As Boolean) As Integer
On Error GoTo BackDoor_Error

'  ?BackDoor(True)  'Enables the Shift Key bypass
'  ?BackDoor(False) 'Disables the Shift Key bypass
'-------------------------------------------

Dim db As Database
Set db = CurrentDb
db.Properties!AllowBypassKey = rbFlag

BackDoor_Exit:
   Exit Function
   
BackDoor_Error:
   If Err = 3270 Then
      'AllowBybassKey property does not exist
      db.Properties.Append _
         db.CreateProperty("AllowBypassKey", _
         dbBoolean, rbFlag)
      Resume Next
   Else
      'Some other error
      MsgBox "Unexpected error: " & Error$ & " (" & Err & ")"
      Resume BackDoor_Exit
   End If

Just press CTRL-G to activate the Debug window and type the function as follows:

   Backdoor(False)

will disable the Shift key bypass.

   Backdoor(True)

will enable it again.

In your database's Startup Options (Tools, Startup) you need to make sure the Use Access Special Keys option is checked so you have the ability to press CTRL-G to run your function.  You can use the AutoKeys macro to disable the F11 key so the user's can't open the Database Window.
0
Comment
Question by:stillgar
  • 8
  • 5
13 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12006172
Dunno if this works with ADPs, but you could try:

Dim db As Object

Set db = CurrentProject
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12006192
I didn't read yoru Q properly, but...

Leave the CurrentProject line out, and that should fix it. If it doesn't, add a reference to DAO (Tools->References, check Microsoft DAO 3.5). Change the line to:
Dim db As DAO.Database
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12006203
Or DAO 3.6....
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:stillgar
ID: 12006368
Adding the reference got the Database.  Now I get the error Object Variable or With BLock Variable not set.  It errors at the point of my Set statement.  It is not able to set to CurrentDB or CurrentProject.  
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12006406
How about:
Set db As Object

?
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12006410
Sorry:

Dim db As Object
0
 

Author Comment

by:stillgar
ID: 12006593
Using:
Dim as Object
Set db = CurrentProject

I get a new error:

Error#2455  You entered an expression that has an invalid reference to the property 'AllowBypassKey'

AllowBypassKey does not show up as a property of CurrentProject in intellisense, but it gives me back the error saying it was an invalid reference to the property.
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12006624
Hmm - try changing this line:
If Err = 3270 Then

To:
If Err = 2455 Then
0
 

Author Comment

by:stillgar
ID: 12006704
No luck
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 500 total points
ID: 12006898
0
 

Author Comment

by:stillgar
ID: 12007552
Thanks a million.  That was just what I needed.

Here is the final function

Public Function Backdoor(Enable As Boolean)
'Backdoor(True) = Disable shift key
'Backdoor(False) = Enable shift key

On Error GoTo BackDoor_Error
'Change the value of the property
    CurrentProject.Properties("AllowBypassKey"). _
        Value = Enable
       
BackDoor_Exit:
MsgBox "Changed to " & Enable
   Exit Function
       
BackDoor_Error:
'If the property has not been added, then add it and set it
'to the value specified in the function (true/ false)
    If Err.Number = 2455 Then
        CurrentProject.Properties.Add "AllowBypassKey", Enable
    Else
        MsgBox "Unexpected error: " & Error$ & " (" & Err.Number & ")"
    End If
       
    Err.Clear

End Function
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12007620
No problem, glad I could help!
0
 

Author Comment

by:stillgar
ID: 12007758
Ack!
Be careful of the comments in the first section!
I switched up backdoor(True/ False).
True opens the backdoor.  False locks it.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question