How can I disable SHIFT+ENTER only for certain users in a MsAccess2002XP database?

  • Thread starter Thread starter Geo
  • Start date Start date
Why would you want to do that? Shift+enter saves a record in a form. If
you stop users doing it that way, there are lots of other ways they can do
it.
 
Excuse me for not being more explicit. I ment to say:
How can I disable SHIFT+ENTER at the opening of the database only for certain users in a MsAccess2002XP database?
 
To use the code to which Lynn points, you need something like:

ChangePropertyDdl "AllowBypassKey", dbBoolean, False

You run that code once, and the next time you open the database, the Shift
Key will not longer do anything. Once you've run the code once, you never
need to run it again (unless you decide to turn the AllowBypassKey on again
by calling replacing False with True)

However, this is an all-or-nothing setting: you cannot do it only for
certain users.
 
I'd like to be able to do this too. Is there some piece of code that could
subsequently be run (by certain users only) to re-enable access to the guts
that become visible if shift-key bypass is used?
 
Angus said:
I'd like to be able to do this too. Is there some piece of code that
could subsequently be run (by certain users only) to re-enable access
to the guts that become visible if shift-key bypass is used?

How about you provide a button, visible to only those certain users, that
displays the database window?
DoCmd.SelectObject acTable, "some table", True
 
Yeaaaaah!!!
Here is a solution:

Option Compare Database
Option Explicit


Public Function dd()
If CurrentUser() <> "admin" Then
If CurrentUser() <> "ChosenUser" Then
ChangeProperty "AllowBypassKey", dbBoolean, False
Else
ChangeProperty "AllowBypassKey", dbBoolean, True
DoCmd.Quit
End If
Else
ChangeProperty "AllowBypassKey", dbBoolean, False
DoCmd.Quit
End If

End Function
Function ChangeProperty(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Integer
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

(C) Mitrica Dan
 
Recognize that changing the value for the AllowBypassKey property changes
things for the next time you use the database.

That means that if PersonA uses the database, you're going to set it so that
the next time they go to use it, they won't be able to use Shift-Enter.
However, if ChosenUser is the next person to use the database, they won't be
able to use Shift-Enter either: they'll have to shut the application down
and then go in and start it a second time before Shift-Enter will do
anything.

Of course, if PersonA is the next person to use the application after
ChosenUser, then Shift-Enter will also work the next time they go in (but
not subsequent times)
 
Good Morning Geo,

How can we run your code?
I try, but I don't know which values I must give to strPropName,
varPropType, varPropValue.

Could you explain to me the steps to run this code?

Thanks a lot,

José Perdigão
 
Back
Top