Simple code from Access 2003 does not work in Access 2007



    In a database developed in Access 2003 I have a form that displays a list of all database users. The users' details are in a subform. On the form there are 2 buttons to toggle between showing Active users and showing All users.

    Clicking these buttons changes the record source of the subform. This all works fine.

    I've just found out that if I open the database in Access 2007, the code does not work. The subform just goes blank and no data is displayed at all.


    Here's the code for the Show All button:
    Private Sub btnAll_Click()
        DoCmd.GoToControl "btnClose"
        Me.frmUsersSub.RecordSource = "qryFrmUsersSubAll"
        Me.btnAll.Visible = False
        Me.btnActive.Visible = True
    End Sub


    Here's the code for the Show Active Only button:
    Private Sub btnActive_Click()
        DoCmd.GoToControl "btnClose"
        Me.frmUsersSub.RecordSource = "qryFrmUsersSubActive"
        Me.btnAll.Visible = True
        Me.btnActive.Visible = False
    End Sub


    The queries work. If I manually change the data source for the subbie, it works. When the form opens the subbies displays correctly (it's default record source is qryFrmUsersSubActive)

    All suggestions welcome. Thank you

    Monday, October 06, 2008 4:10 AM