Try the following sample method:
- Copy the following Code into a Standard Module:
Code:
Public Function GetDuty(ByVal x As Integer)
GetDuty = Choose(x, "Admin", "Mailroom", "Receiption")
End Function
If more options are required then add them to the list above. Selection of option depends on the value passed to the variable x.
- Create a Table (DutyRoster) with the attached Image structure and data.
- Copy and paste the following SQL into the SQL editing Window of a new Query and save it with the Name DutyRosterQ:
Code:
SELECT DutyRoster.Ename,
GetDuty([Mon]) AS Monday,
GetDuty([Tue]) AS Tuesday,
GetDuty([Wed]) AS Wednesday,
GetDuty([Thu]) AS Thursday,
GetDuty([Fri]) AS Friday
FROM DutyRoster;
- Open the DutyRosterQ in Normal view.
If you need to convert a Date to get the number 1,2,3 then use the expression:
Code:
(weekday([DateFieldName]) Mod 3)+1
to get the numbers indicated in the table fields.
You may require a CrossTab Query as Source for the SQL given above instead of the DutyRoster Table.