locked
Access object executing not fired RRS feed

  • Question

  • While MS Access is executing code during the object's event, all other events of the object are locked, so they will not be fired.

    Let's say we have the Microsoft Calendar Control 8.0 ( mscal.ocx ) placed to a form and we have the code: 
    Private Sub Calendar1_Click() 
    Calendar1.Month = 1 + (Calendar1.Month) Mod 12 
    End Sub

    Private Sub Calendar1_NewMonth() 
    MsgBox "Calendar1_NewMonth event" & Calendar1.Month 
    End Sub

    The sample should displays a message box when the user clicks the control. In MS Access, the message box never occurs, as the NewMonth event is called during the Click event. If the exactly the same code is called on VB6, VB/NET the MessageBox is shown each time the user clicks the control. In conclusion, the MS Access can not handle events inside other events.

    Does anyone know if there is any plans to fix this problem ?

    Thursday, January 17, 2019 10:14 AM

All replies

  • Does anyone know if there is any plans to fix this problem ?

    Hi WebCoolNo,

    What happens if you use:

    Private Sub Calendar1_Click() 
      Calendar1.Month = 1 + (Calendar1.Month) Mod 12 
      MsgBox "Calendar1_NewMonth event" & Calendar1.Month 
    End Sub
    

    Imb.

    Thursday, January 17, 2019 10:52 AM
  • The click event, as pointed out by Imb-hb, does not include any MsgBox, you would have to add it.  NewMonth is not a form event so you would either have to make it public and call it or add the MsgBox to the Click event to get the desired result you seek.

    Private Sub Calendar1_Click() 
     Calendar1.Month = 1 + (Calendar1.Month) Mod 12 
     Call Calendar1_NewMonth
    End Sub
    
    Public Sub Calendar1_NewMonth() 
     MsgBox "Cal
    End Sub
    
    Or
    Private Sub Calendar1_Click() 
     Calendar1.Month = 1 + (Calendar1.Month) Mod 12 
     MsgBox "Calendar1_NewMonth event" & Calendar1.Month 
    End Sub

    As a side note, I'd urge you not to use ActiveX controls as much as possible.  Normally, everything can be done using forms and VBA and will avoid you a lot of headaches!


    Daniel Pineault, 2010-2018 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net


    Thursday, January 17, 2019 11:41 AM
  • I think you are missing the point…, the problem is not to show the message box, the example is only to illustrate when MS Access is executing code during the object's event, all other events of the object are locked, so they will not be fired.

    Friday, January 18, 2019 9:59 AM
  • Event can differ between languages, So NET may expose an event which will not exist in VBA which is what I'm assuming is going on here (just my gut). The above will solve your problem and allow you to move forward.

    Daniel Pineault, 2010-2018 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    Friday, January 18, 2019 12:54 PM