Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    London, United Kingdom
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disabling Events (Access 2000)

    Hi there.

    I would like to temporarily disable events on my access form. If i were to do this in excel I would do:
    Application.EnableEvents = False
    and then to switch them back on:
    Application.EnableEvents = True
    Is there an equivilent for this in Access?

    As always any help is much appreciated

    Amanda

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Disabling Events (Access 2000)

    In general, this isn't necessary in Access, since modifying a value in code won't trigger the same events that modifying a value by hand does, so you're much less likely to cause a cascade of events than in Excel.
    Why do you want to turn of event handling? What are you trying to accomplish.

  3. #3
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    London, United Kingdom
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling Events (Access 2000)

    I have a combo box on a form, when the user chooses a value, the form is filtered to display that value. Infact, I have 3 such filters on the same form, so that the user can filter on up to 3 fields.
    When the user Removes the filter, I want to remove the text in the combo boxes, so the user can see that there is no filter on. But when I change the text in the combo box, it runs the code associated with that combo box.

    Example of my code is
    Private Sub cboHome_Click()
    ApplyFilter
    End Sub

    Private Sub cboFilter_Click()
    ApplyFilter
    End Sub

    Private Sub chkExclude_Click()
    ApplyFilter
    End Sub

    Sub ApplyFilter()
    Dim strAPPLY As String
    strAPPLY = ""
    If Len(Me.Home) > 0 Then
    Me.cboHome.SetFocus
    strAPPLY = "home = '" & cboHome.Text & "'"
    End If
    If Len(Me.cboFilter) > 0 Then
    Me.cboFilter.SetFocus
    strAPPLY = "status = '" & cboFilter.Text & "'"
    End If
    If Len(Me.cboAreaFilter) > 0 Then
    Me.cboAreaFilter.SetFocus
    If Len(strAPPLY) > 0 Then
    strAPPLY = strAPPLY & " AND "
    End If
    strAPPLY = strAPPLY & "area = '" & cboAreaFilter.Text & "'"
    End If
    If Me.chkExclude.Value = True Then
    Me.chkExclude.SetFocus
    If Len(strAPPLY) > 0 Then
    strAPPLY = strAPPLY & " AND "
    End If
    strAPPLY = strAPPLY & "Not (qryStaffCRB.CRBCheckStatus) = 'left'"
    End If
    Me.Filter = strAPPLY
    Me.FilterOn = True
    End Sub



    Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
    If ApplyType = acShowAllRecords Then
    Me.cboAreaFilter.SetFocus
    Me.cboAreaFilter.Text = ""
    Me.cboFilter.SetFocus
    Me.cboFilter.Text = ""
    Me.cboHome.SetFocus
    Me.cboHome.Text = ""
    Me.chkExclude.SetFocus
    Me.chkExclude.Value = False
    End If
    End Sub

    Many thanks for your help

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Disabling Events (Access 2000)

    Instead of

    Me.cboAreaFilter.SetFocus
    Me.cboAreaFilter.Text = ""

    try this:

    Me.cboAreaFilter = Null

    Also, I'd use the After Update event of the combo boxes instead of the On Click event. No need to filter if the user hasn't changed anything - or is there?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •