Overriding the Shift Key on open

L

Lynda

I have determined how to override the use of the shift key when opening the
database by setting the "AllowBypassKey" property to false. However, once I
do this, how do I get into the database to make design changes??? Only way I
can see is to keep an unlocked copy for design changes and add the lock when
I distribute the front end. Any suggestions???
 
A

Allen Browne

You can set this property programmatically, from another database that you
use to maintain your databases.

For example, using the function below:
Set db = OpenDatabase("C:\SomeFolder\SomeFile.mdb")
Call ChangeProperty(db, "AllowBypassKey", dbBoolean, False)

Function ChangeProperty(dbs As Database, strPropName As String, _
varPropType As Variant, varPropValue As Variant) As Integer
Dim prp As Property
Const conPropNotFoundError = 3270

On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True
Debug.Print strPropName & " is " & varPropValue

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 'Any other error.
ChangeProperty = False
Resume Change_Bye
End If
End Function

What I personally do is to use code like this to set the
StartupShowDBWindow, AllowSpecialKeys, and AllowBypassKey properties of the
MDE that will become the new front end for users, each time I release a new
version. The development version (MDB) never has these properties set.
 
D

Douglas J. Steele

Based on a thread in another newsgroup, I'd recommend using

Dim prp As DAO.Property

rather than simply

Dim prp As Property
 
L

Lynda

Thanks a bunch. I'll give it a try.
Lynda

Allen Browne said:
You can set this property programmatically, from another database that you
use to maintain your databases.

For example, using the function below:
Set db = OpenDatabase("C:\SomeFolder\SomeFile.mdb")
Call ChangeProperty(db, "AllowBypassKey", dbBoolean, False)

Function ChangeProperty(dbs As Database, strPropName As String, _
varPropType As Variant, varPropValue As Variant) As Integer
Dim prp As Property
Const conPropNotFoundError = 3270

On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True
Debug.Print strPropName & " is " & varPropValue

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 'Any other error.
ChangeProperty = False
Resume Change_Bye
End If
End Function

What I personally do is to use code like this to set the
StartupShowDBWindow, AllowSpecialKeys, and AllowBypassKey properties of the
MDE that will become the new front end for users, each time I release a new
version. The development version (MDB) never has these properties set.
 
L

Lynda

Thanks a bunch. I'll try it out.
Lynda

Douglas J. Steele said:
Based on a thread in another newsgroup, I'd recommend using

Dim prp As DAO.Property

rather than simply

Dim prp As Property
 
J

Jack Cannon

Lynda,

Allen and Doug have both offered excellent and appropriate suggestions.
However, I will offer another that you may wish to consider. I check to see
if the file is an mde or mdb. If an mde it is set to false everytime the
program runs. If an mdb it is set to true everytime the program runs. In
either case the program has to run at least once to set the property
correctly. Since the mdb file never has the property set to false, it is
always available for diagnostic purposes.

Jack Cannon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top