Solved

Disable shift key in .adp

Posted on 2004-09-08
13
864 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

696 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