Solved

DisableByPassKey Access Data Project

Posted on 2006-11-24
3
310 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
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…

809 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