Listbox of Employees on First Sunday, First Monday, First Tuesday... of each month

JustinN1

New Member
Joined
Jan 27, 2011
Messages
46
I have a table of employees. I need a column that lists a scheduled day for them for the 1st Sunday, 1st Monday, 1st Tuesday, 2nd Sunday, 2nd Monday, or 2nd Tuesday of each month. This will only be one column with the option of the days of the month I just mentioned. The next problem I have is I have a form with a listbox on it. I need those employees listed in the listbox if they match with the current day (1st Sunday, 1st Monday, 1st Tuesday.....)

Sorry if I have not provided enough information. I am fairly new to Access and would appreciate any help.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You need three tables:

tbl_Employees [with fields EmpID, EmpName and anything else you need for employees]

tbl_WorkDays [with field WorkDay]
I would list these as Sun1, Sun2, Sun3, Sun4, Sun5, Mon1, Mon2, Mon3 ... you get the picture.
This is your control table for these.

tbl_Availability [with fields EmpID and WorkDay]
Set your relationships so the EmpID has to be in tbl_Employees and the WorkDay has to be in tbl_WorkDays.
Each employee gets a record for each day they're available:
EmpID 253, Sun1
EmpID 253, Sun2
EmpID 257, Mon1
So, at max, each employee has 35 records.

Then, on your form, assuming you have a drop-down to select the work day [cboWorkDay] and the a button [btnShowAvailable] to show the available employees in a list box [lstAvailableEmps] ...

I would use this in the button_click event:

Private Sub btnShowAvailable_Click()

' verify a work day has been selected
If Nz([cboWorkDay],"") = "" Then
' display appropriate error message
Exit Sub
End If

' declare variables
Dim strSQL as string

' build the SQL string to use for the source
strSQL = "SELECT tbl_Employees.EmpName FROM tbl_Availability INNER JOIN tbl_Employees ON tbl_Availability.EmpID = tbl_Employees.EmpID WHERE (((tbl_Availability.WorkDay) = '" & [cboWorkDay] & "'));"

' update the list box
Me.lstAvailableEmps.RowSource = strSQL
Me.lstAvailableEmps.requery

End Sub


Hope this helps!

UC
 
Upvote 0

Forum statistics

Threads
1,221,788
Messages
6,161,963
Members
451,734
Latest member
Adapt375

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top