Solved

Disable shift key in .adp

Posted on 2004-09-08
13
843 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
 

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now