i have a Tool Bar with 6 buttons in my form. Also i have a function to set the visibility of the buttons in the toolbar.
When i click on the button, it is showing me a runtime error '13' - Type Mismatch
The code is as follows. Please help me to solve this.
tbrMenu is the toolbar's name
When i click on the button, it is showing me a runtime error '13' - Type Mismatch
The code is as follows. Please help me to solve this.
tbrMenu is the toolbar's name
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
SendKeys vbTab
Exit Sub
End If
If Shift = vbAltMask Then
Select Case KeyCode
Case vbKeyN
If tbrMenu.Buttons(1).Enabled Then
Call FixToolBar(tbrMenu, vbKeyN) ' Shows an error here
Action = dbAdd
sspMaster(0).Enabled = True
Call ClearAll
txtMaster(enmTxtCode).Text = mclsEmpPromotion.NextCode
'dtpProm(enmDtpProm).SetFocus
txtMaster(enmTxtRefCode).SetFocus
End If
=====================================================================
Public Sub FixToolBar(tbrName As Toolbar, Tag As Integer)
Select Case Tag
Case vbKeyN, vbKeyE
tbrName.Buttons(1).Enabled = False
tbrName.Buttons(2).Enabled = False
tbrName.Buttons(3).Enabled = True
tbrName.Buttons(4).Enabled = False
tbrName.Buttons(7).Enabled = True
Case vbKeyA, vbKeyS
tbrName.Buttons(1).Enabled = True
tbrName.Buttons(2).Enabled = True
tbrName.Buttons(3).Enabled = False
tbrName.Buttons(4).Enabled = True
tbrName.Buttons(7).Enabled = False
End Select
End Sub
If KeyCode = vbKeyReturn Then
SendKeys vbTab
Exit Sub
End If
If Shift = vbAltMask Then
Select Case KeyCode
Case vbKeyN
If tbrMenu.Buttons(1).Enabled Then
Call FixToolBar(tbrMenu, vbKeyN) ' Shows an error here
Action = dbAdd
sspMaster(0).Enabled = True
Call ClearAll
txtMaster(enmTxtCode).Text = mclsEmpPromotion.NextCode
'dtpProm(enmDtpProm).SetFocus
txtMaster(enmTxtRefCode).SetFocus
End If
=====================================================================
Public Sub FixToolBar(tbrName As Toolbar, Tag As Integer)
Select Case Tag
Case vbKeyN, vbKeyE
tbrName.Buttons(1).Enabled = False
tbrName.Buttons(2).Enabled = False
tbrName.Buttons(3).Enabled = True
tbrName.Buttons(4).Enabled = False
tbrName.Buttons(7).Enabled = True
Case vbKeyA, vbKeyS
tbrName.Buttons(1).Enabled = True
tbrName.Buttons(2).Enabled = True
tbrName.Buttons(3).Enabled = False
tbrName.Buttons(4).Enabled = True
tbrName.Buttons(7).Enabled = False
End Select
End Sub