Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Shift key 1

Status
Not open for further replies.

sonikudi

Technical User
Sep 9, 2007
81
0
0
US
Hey guys,

Following is my code to disable the shft key. In the past it has worked on other forms but just doesn't want to work on the back end Db. Here is the code
This is how i call it in VB:
Code:
Private Sub Disable_Click()
Const DB_Boolean As Long = 0
ChangeProperty "AllowBypassKey", 0, False
End Sub

When i click on it it gives me the following error 'Runtime error 3259, invalid field data type'

Code:
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
  '============================================================
  '     Purpose: To enable/disable bypass key
  '     Company: AirSep Corporation
  '  Programmer: Shlagha Jain
  '        Date: 12/01/07
  '============================================================
    Dim dbs As Object, prp As Variant
    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

Any help will be great! Thanks
 
If you capture the keystroke on a form, this is way easier:
Code:
Private Sub Form_KeyPress(KeyAscii As Integer)

IF KeyAscii = vbKeyShift Then KeyAscii = vbKeyCancel

End Sub

Money can't buy happiness -- but somehow it's more comfortable to cry in a Corvette than in a Yugo.
 
Try this. Which is basically what you have.
Code:
Private Sub Command4_Click()
'********************************************************
'This Code Disables the Shift Key
On Error Resume Next
Dim db As DAO.Database
Dim prp As DAO.Property
Set db = CurrentDb
Set prp = db.CreateProperty("AllowByPassKey", dbBoolean, False)
db.Properties.Append prp
MsgBox "disabled"

Set db = Nothing
Set prp = Nothing

End Sub

Private Sub Command5_Click()
'********************************************************
'This Code Re-enables the Shift Key
On Error Resume Next
Dim db As DAO.Database
Set db = CurrentDb
db.Properties.Delete "AllowByPassKey"
db.Properties.Refresh
MsgBox "enabled"
Set db = Nothing

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top