I have a table TBStaff with boolean fields to show their type of employment. Staff can have many types of employment (upto 6).
TBStaff
StaffID________ _Autonumber (PK)
Forenames_____T ext
Surname_______T ext
Assessor_______ yes/no
Trainer________ _yes/no
IV_____________ yes/no
etc.
I have a form which lists all the staff (FRMStaffList). I've put option controls on the form for the user to select which type of employment they want to see.
[O].Assessor....(c ontrol named "AssessorChosen ")
[O].Trainer....... .(control named "TrainerChosen" )
[O].IV............ ...(control named "IVChosen")
In the query used for FRMStaffList I could simply put the criteria for the boolean fields as Forms!FRMStaffL ist.AssessorCho sen
i.e.
However, if I do this for all employment types the query will only look for single employment types.
Consider example below:
If I wanted to show just Assessors the query will will evaluate as
This will show only Bill Hicks and not Bill Bailey and Bill Gates.
I tried to use an IIF statement to choose the criteria statement based on the options the user chooses.
e.g.
But this doesn't work, can IIF statements even be used in this way?
Of course I guess I could create a different query based on the options the user chooses but I would have to create an unbelievable amount of queries to do that.
Any help much appreciated.
TBStaff
StaffID________ _Autonumber (PK)
Forenames_____T ext
Surname_______T ext
Assessor_______ yes/no
Trainer________ _yes/no
IV_____________ yes/no
etc.
I have a form which lists all the staff (FRMStaffList). I've put option controls on the form for the user to select which type of employment they want to see.
[O].Assessor....(c ontrol named "AssessorChosen ")
[O].Trainer....... .(control named "TrainerChosen" )
[O].IV............ ...(control named "IVChosen")
In the query used for FRMStaffList I could simply put the criteria for the boolean fields as Forms!FRMStaffL ist.AssessorCho sen
i.e.
Code:
SELECT TBStaff.Assessor, TBStaff.Trainer, TBStaff.IV
FROM TBStaff
WHERE (((TBStaff.Assessor)=[Forms]![FRMStaffList].[AssessorChosen]) AND
((TBStaff.Trainer)=[Forms]![FRMStaffList].[TrainerChosen]) AND
((TBStaff.IV)=[Forms]![FRMStaffList].[IVChosen]));
Consider example below:
Code:
[b]Name Assessor Trainer IV [/b] Bill Hicks True Bill Bailey True True Bill Gates True True Bill Murry True
Code:
SELECT TBStaff.Assessor, TBStaff.Trainer, TBStaff.IV
FROM TBStaff
WHERE (((TBStaff.Assessor)=TRUE) AND
((TBStaff.Trainer)=FALSE]) AND
((TBStaff.IV)=FALSE));
I tried to use an IIF statement to choose the criteria statement based on the options the user chooses.
e.g.
Code:
SELECT TBStaffTmp.TBStaffID, TBStaffTmp.Forenames, TBStaffTmp.Assessor, TBStaffTmp.Trainer, TBStaffTmp.IV
FROM TBStaffTmp
WHERE (((TBStaffTmp.Assessor)=IIf([Forms]![FRMStaffListTMP].[AssessorChosen]=True,True,True Or False)) AND
((TBStaffTmp.Trainer)=IIf([Forms]![FRMStaffListTMP].[TrainerChosen]=True,True,True Or False)) AND
((TBStaffTmp.IV)=IIf([Forms]![FRMStaffListTMP].[IVChosen]=True,True,True Or False)));
But this doesn't work, can IIF statements even be used in this way?
Of course I guess I could create a different query based on the options the user chooses but I would have to create an unbelievable amount of queries to do that.
Any help much appreciated.
Comment