C
CES
All,
I'm sorry for the second post, I thought I solve the problem but I didn't...
I'm trying to figure out how to .SetFocus on a control and then use the .Dropdown property to display the contents of the combo box. The problem I'm encountering is once I move focus on to the control the combo box drops down, flickers, for a moment but then rolls back up.
Once I exit the TypeOf ComboBox, I'm locking/unlocking & enabling/disabling three possible controls using the onExit event of the TypeOf control based on the selected value.
(These form fields are in their tab stop order and are all enabled/unlocked when the new record is first displayed.)
TypeOf - ComboBox
Category - ComboBox
SubCategory - ComboBox
PaymentMethod - TxtBox
FinancalAccount - ComboBox
I'm assuming the problem I'm running into, is occurring because of the function fnEnableDisableTxtBox() because it is somehow changing focus while it is executing. But even if that is so, the code below should still execute properly by setting focus on the PaymentMethod control and then calling the Dropdown property.
If anyone has a clue as to what I am doing wrong I would appreciate any help. Thanks in advance. - CES
I believe the code below will now always fail to execute the dropdown property properly.
Public Function fnEnableDisableTxtBox(controlName As String, actionToTake As String)
' Call fnEnableDisableTxtBox("NameOfTextBox")
' Will Change to opisit of Current State
Dim tmp As Control
Set tmp = Me.Controls(controlName)
If actionToTake <> "Disable" Then
tmp.Enabled = True
tmp.Locked = False
tmp.BackStyle = 1
Else
tmp.Enabled = False
tmp.Locked = True
tmp.BackStyle = 0
End If
End Function
Private Sub TypeOf_Exit(Cancel As Integer)
If Me.TypeOf.Value = 2 Then
Me.FinancalAccount.Value = ""
Call fnEnableDisableTxtBox("Category", "")
Call fnEnableDisableTxtBox("SubCategory", "")
Call fnEnableDisableTxtBox("FinancalAccount", "Disable")
ElseIf Me.TypeOf.Value > 2 Then
If Me.TypeOf.Value = 3 Then
Me.Category.Value = 3
Else
Me.Category.Value = 4
End If
Me.SubCategory.Value = ""
Call fnEnableDisableTxtBox("Category", "Disable")
Call fnEnableDisableTxtBox("SubCategory", "Disable")
Call fnEnableDisableTxtBox("FinancalAccount", "")
Else
Call fnEnableDisableTxtBox("Category", "")
Call fnEnableDisableTxtBox("SubCategory", "")
Call fnEnableDisableTxtBox("FinancalAccount", "")
End If
Me.PaymentMethod.SetFocus
Me.PaymentMethod.Dropdown
End Sub
I'm sorry for the second post, I thought I solve the problem but I didn't...
I'm trying to figure out how to .SetFocus on a control and then use the .Dropdown property to display the contents of the combo box. The problem I'm encountering is once I move focus on to the control the combo box drops down, flickers, for a moment but then rolls back up.
Once I exit the TypeOf ComboBox, I'm locking/unlocking & enabling/disabling three possible controls using the onExit event of the TypeOf control based on the selected value.
(These form fields are in their tab stop order and are all enabled/unlocked when the new record is first displayed.)
TypeOf - ComboBox
Category - ComboBox
SubCategory - ComboBox
PaymentMethod - TxtBox
FinancalAccount - ComboBox
I'm assuming the problem I'm running into, is occurring because of the function fnEnableDisableTxtBox() because it is somehow changing focus while it is executing. But even if that is so, the code below should still execute properly by setting focus on the PaymentMethod control and then calling the Dropdown property.
If anyone has a clue as to what I am doing wrong I would appreciate any help. Thanks in advance. - CES
I believe the code below will now always fail to execute the dropdown property properly.
Public Function fnEnableDisableTxtBox(controlName As String, actionToTake As String)
' Call fnEnableDisableTxtBox("NameOfTextBox")
' Will Change to opisit of Current State
Dim tmp As Control
Set tmp = Me.Controls(controlName)
If actionToTake <> "Disable" Then
tmp.Enabled = True
tmp.Locked = False
tmp.BackStyle = 1
Else
tmp.Enabled = False
tmp.Locked = True
tmp.BackStyle = 0
End If
End Function
Private Sub TypeOf_Exit(Cancel As Integer)
If Me.TypeOf.Value = 2 Then
Me.FinancalAccount.Value = ""
Call fnEnableDisableTxtBox("Category", "")
Call fnEnableDisableTxtBox("SubCategory", "")
Call fnEnableDisableTxtBox("FinancalAccount", "Disable")
ElseIf Me.TypeOf.Value > 2 Then
If Me.TypeOf.Value = 3 Then
Me.Category.Value = 3
Else
Me.Category.Value = 4
End If
Me.SubCategory.Value = ""
Call fnEnableDisableTxtBox("Category", "Disable")
Call fnEnableDisableTxtBox("SubCategory", "Disable")
Call fnEnableDisableTxtBox("FinancalAccount", "")
Else
Call fnEnableDisableTxtBox("Category", "")
Call fnEnableDisableTxtBox("SubCategory", "")
Call fnEnableDisableTxtBox("FinancalAccount", "")
End If
Me.PaymentMethod.SetFocus
Me.PaymentMethod.Dropdown
End Sub