J
Jen
I have a list box containing employee names; I want to toggle it back and
forth between showing all employees and showing just current employees.
Employees are stored in an Employees Table with FName, LName, Init (a
shortened max 8-character version of their name) and a yes/no field to
determine whether they're active or not.
The AllEmployeesFullName query pulls FName and LName into a calculated
FullName field.
The ActiveEmployees query pulls FName and LName into a calculated FullName
field, plus selects only employees whose status is active.
My list box is based on the ActiveEmployees query with the following
RowSource:
SELECT ActiveEmployees.Init, ActiveEmployees.FullName FROM ActiveEmployees
ORDER BY ActiveEmployees.FullName
The form also contains a command button with the following code:
Private Sub Command10_Click()
If Me!lstEmployees.RowSource = "SELECT ActiveEmployees.Init,
ActiveEmployees.FullName FROM ActiveEmployees ORDER BY
ActiveEmployees.FullName;" Then
Me!lstEmployees.RowSource = "SELECT AllEmployeesFullName.Init,
AllEmployeesFullName.FullName FROM AllEmployeesFullName ORDER BY
AllEmployeesFullName.FullName;"
ElseIf Me!lstEmployees.RowSource = "SELECT AllEmployeesFullName.Init,
AllEmployeesFullName.FullName FROM AllEmployeesFullName ORDER BY
AllEmployeesFullName.FullName;" Then
Me!lstEmployees.RowSource = "SELECT ActiveEmployees.Init,
ActiveEmployees.FullName FROM ActiveEmployees ORDER BY
ActiveEmployees.FullName;"
End If
Me!lstEmployees.Requery
End Sub
This was a simple attempt to get the toggling to work but when I click the
button, nothing happens. I have tried both the code strings as the row
source, and they both do what they're supposed to do (i.e., list either all
employees or only active employees), but the button won't toggle between them.
What am I missing here?
Thanks in advance,
Jen
forth between showing all employees and showing just current employees.
Employees are stored in an Employees Table with FName, LName, Init (a
shortened max 8-character version of their name) and a yes/no field to
determine whether they're active or not.
The AllEmployeesFullName query pulls FName and LName into a calculated
FullName field.
The ActiveEmployees query pulls FName and LName into a calculated FullName
field, plus selects only employees whose status is active.
My list box is based on the ActiveEmployees query with the following
RowSource:
SELECT ActiveEmployees.Init, ActiveEmployees.FullName FROM ActiveEmployees
ORDER BY ActiveEmployees.FullName
The form also contains a command button with the following code:
Private Sub Command10_Click()
If Me!lstEmployees.RowSource = "SELECT ActiveEmployees.Init,
ActiveEmployees.FullName FROM ActiveEmployees ORDER BY
ActiveEmployees.FullName;" Then
Me!lstEmployees.RowSource = "SELECT AllEmployeesFullName.Init,
AllEmployeesFullName.FullName FROM AllEmployeesFullName ORDER BY
AllEmployeesFullName.FullName;"
ElseIf Me!lstEmployees.RowSource = "SELECT AllEmployeesFullName.Init,
AllEmployeesFullName.FullName FROM AllEmployeesFullName ORDER BY
AllEmployeesFullName.FullName;" Then
Me!lstEmployees.RowSource = "SELECT ActiveEmployees.Init,
ActiveEmployees.FullName FROM ActiveEmployees ORDER BY
ActiveEmployees.FullName;"
End If
Me!lstEmployees.Requery
End Sub
This was a simple attempt to get the toggling to work but when I click the
button, nothing happens. I have tried both the code strings as the row
source, and they both do what they're supposed to do (i.e., list either all
employees or only active employees), but the button won't toggle between them.
What am I missing here?
Thanks in advance,
Jen