zelarra821
Registered User.
- Local time
- Today, 17:11
- Joined
- Jan 14, 2019
- Messages
- 835
Buenas tardes. It seems to me that what I am going to ask is a utopia and, therefore, the solution is through the simple path.
The thing is, I have developed a class module to disable all hotkeys. I want this to be executed automatically in each form without having to add lines of code to each form to activate it. I don't know if I explain myself.
I will try to do it graphically.
I have this class module:
To start it in each of the forms, I have to create a variable for the entire form in question, at the beginning of the code, like this:
Then, in the On_Load event, start the class module like this:
What I want is to avoid having to add those two lines of code in each form. I have databases with many forms and it would be a huge gig.
Thank you so much.
The thing is, I have developed a class module to disable all hotkeys. I want this to be executed automatically in each form without having to add lines of code to each form to activate it. I don't know if I explain myself.
I will try to do it graphically.
I have this class module:
Code:
Option Compare Database
Option Explicit
Private WithEvents Form As Access.Form
Private mPresionarTecla As Boolean
Private Const acRichtext = 1
Public Sub InitalizeAutokeys(FName As Form, Optional Ptecla As Boolean = True)
Set Form = FName
Me.PresionarTecla = Ptecla
Form.OnKeyDown = "[Event Procedure]"
Form.KeyPreview = True
End Sub
Public Property Get PresionarTecla() As Boolean
PresionarTecla = mPresionarTecla
End Property
Public Property Let PresionarTecla(ByVal vNewValue As Boolean)
mPresionarTecla = vNewValue
End Property
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Me.PresionarTecla Then
Select Case KeyCode
Case vbKeyF1, vbKeyF5, vbKeyF6, vbKeyF9, vbKeyF10, vbKeyF12
KeyCode = 0
End Select
Select Case Shift
Case 2
Select Case KeyCode
Case vbKeyV
If Form.ActiveControl.controlType = acTextBox Then
Dim txt As TextBox
Set txt = Form.ActiveControl
If txt.TextFormat = acRichtext Then
KeyCode = 0
rbPegarSinFormato
End If
End If
Case Else
KeyCode = 0
End Select
End Select
Select Case KeyCode
Case 18
Select Case KeyCode
Case Else
KeyCode = 0
End Select
End Select
End If
End Sub
Private Sub Class_Terminate()
Set Form = Nothing
End Sub
To start it in each of the forms, I have to create a variable for the entire form in question, at the beginning of the code, like this:
Code:
Dim AutoKeys as New AutoKeys
Then, in the On_Load event, start the class module like this:
Code:
AutoKeys.InitalizeAutokeys Me, True
What I want is to avoid having to add those two lines of code in each form. I have databases with many forms and it would be a huge gig.
Thank you so much.