I have created an unbound form and put in place two unbound toggle buttons labeled current & not current if a user selects either toggle then the relevant data is shown. So if current toggle is selected and the user clicks on the button to show the data it will check the table to see if the field (iscurrent) is true and then shows those records and vice versa for the not current. however i cant seem to get it to bring up the data. my code is as follows:
Private Sub show_agents_Click()
'the user selects the "current" toggle button if they wish to see all current agents
'If the toggle is selected then show the records where the field "iscurrent" is true
If Me.current = True And iscurrent = True Then
Const Showrecords = "SELECT Employees.FirstName, Employees.LastName, Employees.Title, Employees.BirthDate FROM Employees"
'the user selects the "notcurrent" toggle button if they wish to see all noncurrent agents
'If the toggle is selected then show the records where the field "iscurrent" is false
ElseIf Me.notcurrent = True And iscurrent = False Then
Const Showrecords = "SELECT Employees.FirstName, Employees.LastName, Employees.Title, Employees.BirthDate FROM Employees"
'the user has not selected a toggle button if they wish to see all agents
'then all agents will be seen if button is clicked
ElseIf Me.current = False And Me.notcurrent = False Then
Const Showrecords = "SELECT Employees.FirstName, Employees.LastName, Employees.Title, Employees.BirthDate FROM Employees"
End If
End If
End If
iscurrent = DLookup("iscurrent", "[Agent]")
End Sub
Can anyone help to point out where i am going wrong. Thanks
Private Sub show_agents_Click()
'the user selects the "current" toggle button if they wish to see all current agents
'If the toggle is selected then show the records where the field "iscurrent" is true
If Me.current = True And iscurrent = True Then
Const Showrecords = "SELECT Employees.FirstName, Employees.LastName, Employees.Title, Employees.BirthDate FROM Employees"
'the user selects the "notcurrent" toggle button if they wish to see all noncurrent agents
'If the toggle is selected then show the records where the field "iscurrent" is false
ElseIf Me.notcurrent = True And iscurrent = False Then
Const Showrecords = "SELECT Employees.FirstName, Employees.LastName, Employees.Title, Employees.BirthDate FROM Employees"
'the user has not selected a toggle button if they wish to see all agents
'then all agents will be seen if button is clicked
ElseIf Me.current = False And Me.notcurrent = False Then
Const Showrecords = "SELECT Employees.FirstName, Employees.LastName, Employees.Title, Employees.BirthDate FROM Employees"
End If
End If
End If
iscurrent = DLookup("iscurrent", "[Agent]")
End Sub
Can anyone help to point out where i am going wrong. Thanks