Results 1 to 3 of 3
  1. #1
    yosemite is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    2

    Enabling tabs in a Navigation Form (Access 2010) based upon filtered data

    I'm working in Access 2010 and therefore have access to the new Navigation Form that is replacing the old switchboard way of navigating through an application. I have a form that is used as the "Navigation Target Name" on one of the tabs. The form is a continuous form (the Default View property is set to Continuous Forms). Within the form header I provide fields that the user can use to search the data that will be displayed in the continuous form, and a button that they click to actually apply a filter ([Event Procedure] for the On Click event). A SQL "WHERE" clause is built in the VBA code and the filter is applied with the code:
    Code:
     
    Me.Filter = strWhere
    Me.FliterOn = True

    This all works as expected. However, I need to know how many records were found by the filter. I need this information so that I can enable/disable other tabs that rely on a record being selected in the continuous form. If no records have been found I don't want to enable the other tabs because they depend upon data being selected on the continuous form. I used the On Current event, but this only occurs if I actually select a record in the continuous form (and only if I select a record that hasn't been selected by Access after the filter has been applied). I need to be able to enable the other tabs if a record has been found AND selected.
    Is there an event that I can use to verify that there are records that met the filter criteria?


    Is enabling sibling tabs a bad design decision? This seemed natural to me, but I could be wrong.
    Thanks in advance.

  2. #2
    yosemite is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    2

    Post

    I solved my own problem. I didn't realize that my code that was doing the filtering was doing it at the time my code ran. I set the Filter then as soon as I turned it on (Me.FilterOn) Access does the filtering right there before exiting my sub routine. I thought that the filtering would be done after my my sub routine, so I didn't know the event where I could count the records. Here is the code that was placed in my routine:

    Code:
    Private Sub btnApplyFilter_Click()
     
    ' code to build "WHERE" clause
     
    ' filter data
    Me.Filter = strWhere
    Me.FilterOn = True   ' Access does the filtering right after I set property
     
    ' data has been filtered at this point so I can get the recordcount if
    ' any records were found
    If IsNull(Me.Recordset) Then
       MsgBox "No RECORDS!"
    Else
       Dim rstClone As DAO.Recordset
       Set rstClone = Me.RecordsetClone
       rstClone.MoveLast
       MsgBox "rstClone.RecordCount:  " & rstClone.RecordCount
    End If
     
    End Sub

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Thanks for posting back with your success and your solution.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 01-02-2011, 10:09 AM
  2. Banish the Access 2010 Navigation Pane
    By SteveF in forum Access
    Replies: 3
    Last Post: 12-07-2010, 10:44 AM
  3. Corrupt Table in Data Set View Access 2010
    By Peter Murray in forum Access
    Replies: 1
    Last Post: 11-29-2010, 04:16 PM
  4. Problems with data entry form Access 2010
    By OfficeQuestions in forum Access
    Replies: 4
    Last Post: 09-23-2010, 01:42 PM
  5. Replies: 1
    Last Post: 08-22-2010, 12:25 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums