Problem
VBA code to disable backspace key on textbox in MS Access application
Solution
i. Description
This VBA code is used to disable backsapce key on textbox in MS Access application
ii. Procedure
1. Create a form frmMain
2. Place textbox control on form. Lets say the name of textbox is Text0
3. Select textbox (say Text0), right-click then select properties, select Event tab , On KeyDown, select [Event Procedure] from dropdown, click ... button
Copy & paste the following code under KeyDown event of Text0 textbox
Private Sub Text0_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyBack Then
MsgBox ("Backspace key has been disabled")
KeyCode = 0
End If
End Sub
iii.Code
Option Compare Database
Private Sub Text0_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyBack Then
MsgBox ("Backspace key has been disabled")
KeyCode = 0
End If
End Sub
iv. Additional Info
This code will disable the backspace key on textbox. whenever you click this backspace key, it wont work, it just popup a message backspace key has been disabled.