Solved

DisableByPassKey Access Data Project

Posted on 2006-11-24
3
286 Views
Last Modified: 2008-02-01
Hello

I am trying to disable the use of the shift key on startup.  I am using an Access 2003 (Access Data Project).  I am using the change property function on the MS site but it has no effect.

I am using this function....it fails because the dbs variable is set to 'Nothing' when it gets to ' dbs.Properties(strPropName) = varPropValue'


Function ChangeProperty(strPropName As String, _
 varPropType As Variant, varPropValue As Variant) As Integer
' The current listing in Access help file which will
' let anyone who can open the db delete/reset any
' property created by using this function, since
' the call to CreateProperty doesn't use the DDL
' argument
'
 Dim dbs As Database, prp As Property
 Const conPropNotFoundError = 3270

 Set dbs = CurrentDb
 On Error GoTo Change_Err
 dbs.Properties(strPropName) = varPropValue
 ChangeProperty = True

Change_Bye:
 Exit Function

Change_Err:
 If Err = conPropNotFoundError Then ' Property not found.
  Set prp = dbs.CreateProperty(strPropName, _
        varPropType, varPropValue)
  dbs.Properties.Append prp
  Resume Next
 Else
  ' Unknown error.
  ChangeProperty = False
  Resume Change_Bye
 End If
End Function
0
Comment
Question by:doddwell
  • 2
3 Comments
 
LVL 44

Accepted Solution

by:
Leigh Purvis earned 200 total points
ID: 18006701
Function AllowByPass(Allow as Boolean)
    CurrentProject.Properties.Add "AllowBypassKey", Allow
End Function
0
 

Author Comment

by:doddwell
ID: 18006722
Well that was easy...thanks.  Why was I bothering with the complex function?....was that required with earlier versions of Access?
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 18006789
No probs.

It was required back in Access 97.
And I'd say that many developers (myself included) have just kept using their same old stock function.
(I made the above function up just now :-)

It would work in Access 2000 onwards (which is where ADP's can feature too).
Your previous function would generally work in Access 2003 mdb's - but in an ADP there is no Jet engine processing, no DAO library - and the DAO objects (like CurrentDb) aren't created.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

12 Experts available now in Live!

Get 1:1 Help Now