Hi everyone, I introduced myself as I am a new member (although reading this forum for a quite a time now)... guys I have (for me) a serious problem that i cannot solve:
So, I have a table which tracks employees shift schedule (shifts are like 1 - morning shift, 2 - afternoon shift, 3 - night shift and so on) and has field names like [date], [name1], [name2], ... [name10] (don't ask why, the structure of a table has to have fields arranged like this :/
Basically, here's the thing: As employees work 24/7 all of them don't have a weekend free all the time. It happens that a certain employee (because of the shift algorithm) doesn't have a weekend free (Saturday+Sunday) for months. So I created a query that finds, between dates given, how many weekends employee has had.
The thing is that I'd like to manage field names over a form like from a combo box (where i put Row Source Type to Field list) but that doesn't seem to work. So I was wondering if there is a way to do this in VBA (where i lack of a knowledge).
So here it is:
SELECT Count (*) AS [No_Weekends]
FROM
(
SELECT Shift_Table.Date, Shift_Table.[Name1] as Name_Saturday, Shift_Table.Date+1 as Sunday_Date,
(
SELECT A1.[Name1] FROM Shift_Table as A1
WHERE A1.Date = Shift_Table.Date +1) as Name_Sunday
FROM Shift_Table
WHERE CStr(Format([Date],"dddd")
)
In ("Saturday") And Shift_Table.Date Between #1/1/2015# And #12/31/2015#
) AS Weekend
WHERE Len(LTrim(IIf([Name_Saturday],Null,'')=0) AND Len(LTrim(IIf([Name_Sunday],Null,'')=0));
(Query works if I manually put field names, but all of the employees should have access to this DB, and all queries (as long as all other tables) must be invisible to them.)
Many thanks!
--
scukaf
So, I have a table which tracks employees shift schedule (shifts are like 1 - morning shift, 2 - afternoon shift, 3 - night shift and so on) and has field names like [date], [name1], [name2], ... [name10] (don't ask why, the structure of a table has to have fields arranged like this :/
Basically, here's the thing: As employees work 24/7 all of them don't have a weekend free all the time. It happens that a certain employee (because of the shift algorithm) doesn't have a weekend free (Saturday+Sunday) for months. So I created a query that finds, between dates given, how many weekends employee has had.
The thing is that I'd like to manage field names over a form like from a combo box (where i put Row Source Type to Field list) but that doesn't seem to work. So I was wondering if there is a way to do this in VBA (where i lack of a knowledge).
So here it is:
SELECT Count (*) AS [No_Weekends]
FROM
(
SELECT Shift_Table.Date, Shift_Table.[Name1] as Name_Saturday, Shift_Table.Date+1 as Sunday_Date,
(
SELECT A1.[Name1] FROM Shift_Table as A1
WHERE A1.Date = Shift_Table.Date +1) as Name_Sunday
FROM Shift_Table
WHERE CStr(Format([Date],"dddd")
)
In ("Saturday") And Shift_Table.Date Between #1/1/2015# And #12/31/2015#
) AS Weekend
WHERE Len(LTrim(IIf([Name_Saturday],Null,'')=0) AND Len(LTrim(IIf([Name_Sunday],Null,'')=0));
(Query works if I manually put field names, but all of the employees should have access to this DB, and all queries (as long as all other tables) must be invisible to them.)
Many thanks!
--
scukaf