Tried DoEvents as well, but never used that before so didn't really understand what I found on the web for it. Form view is "Continuous Forms", each row has two textboxes (1 for ID, 1 for name), a checkbox (for inactive/active) and a button that opens up the employee detail form. Code is below:
Code:
Private Sub btnInactives_Click()
On Error GoTo Err_btnInactives_Click
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("qryLeasedDriverList")
Dim sqlStr As String
sqlStr = "SELECT [Leased Drivers].EmployeeNumber, [Leased Drivers].LastName, [Leased Drivers].FirstName, [Leased Drivers].Inactive " & _
"FROM [Leased Drivers] "
'default button caption is "Show Inactives"
'if button reads "Hide Inactives" then add WHERE clause to query
If Me.btnInactives.Caption = "Hide Inactives" Then
sqlStr = sqlStr & "WHERE((([Leased Drivers].Inactive) = False)) "
Me.btnInactives.Caption = "Show Inactives"
Else
Me.btnInactives.Caption = "Hide Inactives"
End If
sqlStr = sqlStr & "ORDER BY [Leased Drivers].EmployeeNumber;"
qdf.SQL = sqlStr
DoEvents
Me.Requery
Exit_btnInactives_Click:
Exit Sub
Err_btnInactives_Click:
MsgBox Err.Description
Resume Exit_btnInactives_Click
End Sub