Click here to Skip to main content
15,891,597 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i have an MSA database programmed with VBA, i have a sub-form contains a group of combo boxes.
problem:
when i click on any combo box to change its value it does not change at the first try, it does on the second try and all the others then can be changed from the first try.

I've analyzed the problem, i found that the event click did not fire at the first time while the events mouse-down, got_focus, mouse_up, and on_dirty etc.. do.

why a n event didn't fire, is there any explanation?

thank you.

[Update from OP(Moved from Comments)]

VB
Private Sub nb1_AfterUpdate()
      Dim ctlX As Control
 
      If IsNull(Me.nb1.Value) Then Exit Sub
      
      Me.nb2.enabled = Not Me.nb1.Value
      nb2_AfterUpdate
      
      For Each ctlX In Me.Controls
            If Me.nb1.Value Then
                  If Left(ctlX.name, 3) = "nb3" Then
                        If TypeOf ctlX Is Label Then
                              If Me.nb1.Value Then
                                    ctlX.ForeColor = 10987431
                              Else
                                    ctlX.ForeColor = 16711680
                              End If
                        Else
                              Select Case ctlX.name
                                    Case "nb3box"
                                    Case "nb3Ftext"
                                          nb3F_AfterUpdate
                                    Case Else
                                          ctlX.enabled = Not Me.nb1.Value
                              End Select
                        End If
                  End If
            End If
            
            If Left(ctlX.name, 3) = "nb4" Then
                  If TypeOf ctlX Is Label Then
                        If Me.nb1.Value Then
                              ctlX.ForeColor = 16711680
                        Else
                              ctlX.ForeColor = 10987431
                        End If
                  Else
                        ctlX.enabled = Me.nb1.Value
                  End If
            End If
      Next
      
      nb4_AfterUpdate
      
      Me.nb5.enabled = Me.nb1.Value
      Me.nb5a.enabled = Me.nb1.Value
      nb5a_AfterUpdate
      Me.nb6.enabled = Me.nb1.Value
      Me.nb7.enabled = Me.nb1.Value
      Me.nb7Why.enabled = Me.nb1.Value
 
End Sub
 
Private Sub nb8aNoNoNeed_AfterUpdate()
      Dim ctlX As Control
      
      If Not Me.nb8aNoNoNeed.enabled Then Exit Sub
      
      nb9_Set Not Me.nb8aNoNoNeed.Value
End Sub
 
Private Sub nb9rankingA_AfterUpdate()
      nb9_Check
End Sub
 
Private Sub nb9rankingB_AfterUpdate()
      nb9_Check
End Sub
 
Private Sub nb9rankingC_AfterUpdate()
      nb9_Check
End Sub
 
Private Sub nb9rankingD_AfterUpdate()
      nb9_Check
End Sub
 
Private Sub nb9rankingE_AfterUpdate()
      nb9_Check
End Sub
 
Private Sub nb9rankingF_AfterUpdate()
 
      If Not Me.nb9rankingF.enabled Then
            Me.noLoanReasonFtext.enabled = False
            Exit Sub
      End If
 
      If Me.nb9rankingF.Value = 0 Then
            Me.noLoanReasonFtext.enabled = False
      Else
            Me.noLoanReasonFtext.enabled = True
      End If
      
      nb9_Check
      
End Sub
 
Public Function nb9_Check() As Boolean
      Const iRankCount As Byte = 6
      Dim nb9rankings(iRankCount) As Variant
   
      Dim i As Long
      
      Dim nb9rank As Control
      Dim nb9Label As Control
      
      nb9_Check = True
      
      If Not Me.nb9.enabled Then Exit Function
 
      For i = 0 To iRankCount - 1
            nb9rankings(i) = ""
      Next i
 
      For Each nb9rank In Me.Controls
            If Left(nb9rank.name, 10) = "nb9ranking" Then
                  If nb9rank.Value = 0 Then
                        nb9rank.Controls.Item(0).BackStyle = 1
                        nb9rank.Controls.Item(0).BackColor = -2147483633
                  ElseIf nb9rank.Value > 0 Then
                        If nb9rankings(nb9rank.Value) = "" Then
                              nb9rankings(nb9rank.Value) = nb9rank.Controls.Item(0).name
                              nb9rank.Controls.Item(0).BackStyle = 1
                              nb9rank.Controls.Item(0).BackColor = -2147483633
                        Else
                              nb9rank.Controls.Item(0).BackStyle = 1
                              nb9rank.Controls.Item(0).BackColor = 65535
                              For Each nb9Label In Me.Controls
                                    If nb9Label.name = nb9rankings(nb9rank.Value) Then
Posted
Updated 26-Sep-11 1:42am
v2
Comments
VK k 26-Sep-11 5:41am    
post your code?
Maciej Los 27-Sep-11 11:52am    
Where is a focus (cursor of mouse)?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900