shift toets blokkeren

Status
Niet open voor verdere reacties.

RSpan

Gebruiker
Lid geworden
10 jun 2009
Berichten
166
Hoi forumleden:thumb:

Weet iemand hoe je er voor kan zorgen dat het openen, met de shift toets ingedrukt, van de dbase dit er niet voor zorgt dat men dan bij de formulieren, query's e.d. kan komen.
Kortom dat de shift toets geen functie heeft bij het openen van de dbase.
Ik heb gezocht maar vind alleen een bestandje die dit voor oudere versies oplost, ik werk met 2007, en daar werkt het niet op.:(

Mvg
René
 
Heb je hier al gekeken? Of Hier?

Hoi Michel

ik heb een van de voorbeelden gebruikt t.w.

Code:
Function ap_DisableShift()
'This function disable the shift at startup. This action causes
'the Autoexec macro and Startup properties to always be executed.
On Error GoTo errDisableShift
Dim db As DAO.Database
Dim prop as DAO.Property
Const conPropNotFound = 3270
Set db = CurrentDb()
'This next line disables the shift key on startup.
db.Properties("AllowByPassKey") = False
'The function is successful.
Exit Function
errDisableShift:
'The first part of this error routine creates the "AllowByPassKey
'property if it does not exist.
If Err = conPropNotFound Then
Set prop = db.CreateProperty("AllowByPassKey", _
dbBoolean, False)
db.Properties.Append prop
Resume Next
Else
MsgBox "Function 'ap_DisableShift' did not complete successfully."
Exit Function
End If
End Function
Function ap_EnableShift()
'This function enables the SHIFT key at startup. This action causes
'the Autoexec macro and the Startup properties to be bypassed
'if the user holds down the SHIFT key when the user opens the database.
On Error GoTo errEnableShift
Dim db as DAO.Database
Dim prop as DAO.Property
Const conPropNotFound = 3270
Set db = CurrentDb()
'This next line of code disables the SHIFT key on startup.
db.Properties("AllowByPassKey") = True
'function successful
Exit Function
errEnableShift:
'The first part of this error routine creates the "AllowByPassKey
'property if it does not exist.
If Err = conPropNotFound Then
Set prop = db.CreateProperty("AllowByPassKey", _
dbBoolean, True)
db.Properties.Append prop
Resume Next
Else
MsgBox "Function 'ap_DisableShift' did not complete successfully."
Exit Function
End If
End Function



In the Visual Basic editor, click Immediate Window on the View menu.
If you want to disable the SHIFT key, type ap_DisableShift in the Immediate window, and then press ENTER. If you want to enable the shift key, type ap_EnableShift in the Immediate window, and then press ENTER.


deze werkt prima maar ik begrijp één ding niet.
wanneer ik ap_DisableShift heb ingetypte kan ik dat volgens mij niet meer ongedaan maken.
en zoals het voorbeeld aangeeft ap_EnableShift intypen om de shiftfunctie weer te activeren.
of zie ik iets over het hoofd?:confused:
mvg
René

Hoi Michel

ik heb de andere funcie gebruikt die werkt uitstekend.
zo kun je de shift funcie aan en uit zetten.

Code:
'***************** Code Start ***************
'Copy this function into a new public module.

Option Compare Database
Option Explicit

Public Function SetProperties(strPropName As String, _
varPropType As Variant, varPropValue As Variant) As Integer

    On Error GoTo Err_SetProperties

    Dim db As DAO.Database, prp As DAO.Property

    Set db = CurrentDb
    db.Properties(strPropName) = varPropValue
    SetProperties = True
    Set db = Nothing

Exit_SetProperties:
    Exit Function

Err_SetProperties:
    If Err = 3270 Then    'Property not found
        Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
        db.Properties.Append prp
        Resume Next
    Else
        SetProperties = False
        MsgBox "SetProperties", Err.Number, Err.Description
        Resume Exit_SetProperties
    End If
End Function
'***************** Code End ***************

Once you have created the module, then you will need to attach the following code to a command button (or label, graphic etc.):

Code:
'***************** Code Start ***************
'Assign this to the OnClick event of a command button (or double-click event
'of a label or graphic) named "bDisableBypassKey"
'Change the "TypeYourBypassPasswordHere" default password to your password

Private Sub bDisableBypassKey_Click()
    On Error GoTo Err_bDisableBypassKey_Click
    'This ensures the user is the programmer needing to disable the Bypass Key
    Dim strInput As String
    Dim strMsg As String
    Beep
    strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & _
             "Please key the programmer's password to enable the Bypass Key."
    strInput = InputBox(Prompt:=strMsg, title:="Disable Bypass Key Password")
    If strInput = "TypeYourBypassPasswordHere" Then
        SetProperties "AllowBypassKey", dbBoolean, True
        Beep
        MsgBox "The Bypass Key has been enabled." & vbCrLf & vbLf & _
               "The Shift key will allow the users to bypass the startup & _
               options the next time the database is opened.", _
               vbInformation, "Set Startup Properties"
    Else
        Beep
        SetProperties "AllowBypassKey", dbBoolean, False
        MsgBox "Incorrect ''AllowBypassKey'' Password!" & vbCrLf & vbLf & _
               "The Bypass Key was disabled." & vbCrLf & vbLf & _
               "The Shift key will NOT allow the users to bypass the & _
               startup options the next time the database is opened.", _
               vbCritical, "Invalid Password"
        Exit Sub
    End If
Exit_bDisableBypassKey_Click:
    Exit Sub
Err_bDisableBypassKey_Click:
    MsgBox "bDisableBypassKey_Click", Err.Number, Err.Description
    Resume Exit_bDisableBypassKey_Click
End Sub
'***************** Code End ***************

prima:thumb:
en weer reuze bedankt voor je input :thumb: :D
groet
René
 
Laatst bewerkt:
Hallo Rene,

Ik heb gekeken naar de code die je hebt gebruikt (de laatste).

Deze zou ik ook wel graag willen gebruiken.

Mijn Access programma start offercieel met een splash screen (een formulier met de titel van het programma), na paar seconden sluit deze, en word een inlog formulier geopent.

Voor de eerste code moet ik een nieuwe module maken, dat is geen probleem. Alleen waar zou ik de tweede code moeten plaatsen? Ik las wel

"then you will need to attach the following code to a command button (or label, graphic etc.):"

Moet ik hiervoor nog een formulier maken of zo?

Hopelijk kan je en wil je me even de weg wijzen.

Met vriendelijke groet,

Jelle Ruben
 
De tweede code moet je koppelen aan een element op je formulier, zoals al is aangegeven. Dat kan een knop zijn, waarop je klikt, of een object op het formulier zodat je bij het laden van het formulier die code laat draaien. Die keuze is aan jou.
 
Okay, is het de bedoeling dan men die er mee gaat werken ook echt op die knop moeten drukken? of kan ik ook die code laten laden door dat het ene scherm sluit en de andere opent?
 
Dat kan inderdaad. De hele routine staat tussen de regels Private Sub bDisableBypassKey_Click() en End Sub. Hoe en wanneer je die laat uitvoeren, boeit eigenlijk niet. Alleen moet je oppassen dat je dit soort codes wel 'in de hand houdt'; je wilt niet dat er op momenten dat je het niet wilt een routine wordt afgevuurd waardoor je db ontwricht raakt.... Daarom gebruik ik de routine zelf met een knop die alleen voor bepaalde gebruikers(groepen) zichtbaar is. Mijn opvatting is dus dat je het aan- en uitschakelen een bewust actie moet zijn, en geen automatische.
 
Sorry dat ik even terug kom op deze topic, ik heb deze code ook gecopieerd maar bij mij lijkt het niet te lukken.
blijkbaar moet men volgende aanpassingen doen in de verwijzingen en dit lijkt bij mij niet te lukken (ik werk met windows 7 64 bit, mss is dat de reden?
ik krijg volgende boodschap, " de opgegeven naam is strijdig met een bestaand project, een bestaande module of een bestaande objectenbibliotheek" ook weet ik niet hoe of waar ik Select "files of type ergens moet terugvinden.
Kan iemand mij hier mee verder helpen?
groeten,
Rik
You might have to set your "References" in the VBA editor to DAO 3.6.
When you are viewing a Module, click the Tools menu » References. Browse for Microsoft DAO 3.6
Select "Files of type: Executable Files (*.exe; *.dll)"
C:\Program Files\Common Files\Microsoft Shared\DAO)
Then explicitly dimension yourcode, i.e. Dim db As DAO.Database, prp As DAO.Property
 
1. Het topic is redelijk gedateerd.
2. Je breekt in, in iemand zijn topic. Beide zijn niet gewenst. Graag een eigen topic maken.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan