Shift ByPass Key Disable revisited

G

Guest

I have used Michael Kaplan's function 'ChangePropertyDdl' in a prior version
of a database I am the owner of; with continued success.

However; when attempting to use the same code in a new version of the same
database it does not function as expected. When the function is called it
has no effect at all in preventing the next user logging in from using the
shift key to bypass the autoexec.

The current database I wish to implement the function on is Access 2002 SP-2.
I have logged on as owner and have full permissions. The database is split
FE / BE. I tried copying the exact code from the prior database and pasting
it into a new module and have copied the command button code as well to
assure everything is the same. No success.

Anyone have any idea why this doesn't work?
 
T

TC

Hard to say w/o seeing your code. You might have changed it from the
original, inadvertantly. Post it here so someone can comment.

HTH,
TC
 
G

George Nicholson

...and have copied the command button code as well to assure everything is
the same...

When you copied the command button code, did you also set the "new" db
command button Click event property to point to the copied code?

HTH,
 
G

Guest

Opps!

The call should have been typed as:

ChangePropertyDdl "AllowBypassKey", dbBoolean, False
 
G

Guest

Function ChangePropertyDdl(stPropName As String, _
PropType As DAO.DataTypeEnum, vPropVal As Variant) _
As Boolean
' Uses the DDL argument to create a property
' that only Admins can change.
'
' Current CreateProperty listing in Access help
' is flawed in that anyone who can open the db
' can reset properties, such as AllowBypassKey
'
On Error GoTo ChangePropertyDdl_Err

Dim DB As DAO.Database
Dim prp As DAO.Property

Const conPropNotFoundError = 3270

Set DB = CurrentDb
' Assuming the current property was created without
' using the DDL argument. Delete it so we can
' recreate it properly
DB.Properties.Delete stPropName
Set prp = DB.CreateProperty(stPropName, _
PropType, vPropVal, True)
DB.Properties.Append prp

' If we made it this far, it worked!
ChangePropertyDdl = True

ChangePropertyDdl_Exit:
Set prp = Nothing
Set DB = Nothing
Exit Function

ChangePropertyDdl_Err:
If Err.Number = conPropNotFoundError Then
' We can ignore when the prop does not exist
Resume Next
End If
Resume ChangePropertyDdl_Exit
End Function
--

Call from the command button:

ChangeProperty "AllowBypassKey", dbBoolean, False




Rick in N S
 
T

TC

Well, I guess the obvious questions are:

- are you sure that you are actually /executing/ any of that code? Put
a msgbox in ChangePropertyDdl, just to be sure.

- are you sure that the startup properties are being set correctly, so
that there /is/ actually something to disable the bypasskey for? In
other words, how do you know that it is not actually working?

If necessary you could check the current value of the property, by
executing this code from some other database:

(untested)

dim db as database, s as string
set db = dbengine.opendatabase("full path to the database containing
the property")
on error resume next
s = db.properties![allowbypasskey]
if err.number <> 0 then s = err.description
on error goto 0
msgbox s
set db = nothing

HTH,
TC
 
G

George Nicholson

Sorry, perhaps my question should have been phrased differently:
is the "OnClick" event of your new command button set to [Event
Procedure] and if you click on the ellipse... to the right of that setting,
does it take you to the code you expect to run?

HTH,
 
G

Guest

I have confirmed with a message box after ChangePropertyDdl the call the
function is running.

I ran the code you supplied from two different databases and both times
received a message box stating "Property Not Found"

The startup options 'Use Special Keys' has been checked.

Interestingly I changed the call to "ChangeProperty" from
"ChangePropertyDdl" to see if the code in the second part of Kaplan's posting
would run on this database. I received a 'Run-time error 13 - Type mismatch'

I must be missing something somewhere.

Any other suggestions on how to resolve this problem ?
 
G

Guest

Yes, I have confirmed the code is running. See other posting to TC.
--
Rick in N S


George Nicholson said:
Sorry, perhaps my question should have been phrased differently:
is the "OnClick" event of your new command button set to [Event
Procedure] and if you click on the ellipse... to the right of that setting,
does it take you to the code you expect to run?

HTH,
--
George Nicholson

Remove 'Junk' from return address.
 
T

TC

Rick said:
I have confirmed with a message box after ChangePropertyDdl the call the
function is running.

Ok, the function is running.
I ran the code you supplied from two different databases and both times
received a message box stating "Property Not Found"

So the function is running, but it is not creating the property. This
would explain why the bypass key has not been suppressed. We need to
find out /why/ the property has not been created.

Temporarily change the code within the ChangePropertyDdl functiion, by
adding the line that is shown below:

DB.Properties.Delete stPropName
ON ERROR GOTO 0 '<<<<<<
Set prp = DB.CreateProperty(stPropName, _
PropType, vPropVal, True)
DB.Properties.Append prp

Then run the function again. This will show you whether an error is
occuring (and what it is) on the createproperty or append statements.
(No errors should occur on those statements.)

If the function is running, and /no/ errors occur, but you still say
the property does not exist, then, I'd be a bit stumped without being
able to see the actual database. I'm sure the problem is simple, it's
just hard to diagnose by remote control.

Interestingly I changed the call to "ChangeProperty" from
"ChangePropertyDdl" to see if the code in the second part of Kaplan's posting
would run on this database. I received a 'Run-time error 13 - Type mismatch'

Um, you can't just change names randomly & expect it to work! That's
like filling you car with water instead of gas, to see what will
happen. :)

Don't try to debug by messing around to see if that fixes it. Instead,
make some logical hypotheses, eg. "perhaps the property does not
exist", then design & run some tests to see if those hypotheses are
true, or false. That way you will proceed slowly, but inexorably,
towards finding the error.

HTH,
TC
 
G

Guest

Ran the function again with the code you have supplied. Compiled. Ran
without error to the message box after the call indicating it had run
through. ?????

If you are willing to take a look at the entire database please advise how
to transfer.
Appreciate your help.
 
G

Guest

Further to me earlier post today. I tried creating two new dbs and imported
the tables to a new front-end and back-end. Refreshed the links. Tried
compile and was presented with a compile error: user-defined type not
defined on the ChangePropertyDdl function. The error rose with the following
lines highlighted:

Function ChangePropertyDdl(stPropName As String, _
PropType As DAO.DataTypeEnum, vPropVal As Variant) _
As Boolean

Not sure is this may identify some area to focus on or not; for what's its
worth.
 
G

Guest

TC:

After tooling around with this thing for the past few days I finally located
the answer via a Google search provided by Douglas J. Steele, MVP in his
comments on Aug 26 at 10:54PM in the 'Securtiy Newgroups' which can be found
at:

http://www.secnewsgroups.net/group/microsoft.public.access.security/topic3123.aspx

The issue appears to related to trapping Err.Number 3265 in addition to
Err.Number 'conPropNotFoundError

I used Douglas's code in the error handler and voila! it works like a top.
I don't fully understand the process or why I wasn't getting the 3265 error
notification; but it works.

Thank you for your interest in this problem and thanks to Douglas Steele for
his help which I am sure many frustrated developers will certainly appreciate.
 

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