Hi All,
I am out of ideas so I am turning to the experts for help.
What I need to do is select an employee from a combo box (Combo58) and then have another combo box (Combo36) only display holidays with a holiday date greater than or equal to the selected employee’s anniversary date (annDate)
I seem to have much of this worked out except the WHERE clause. I simply do not know how to select the correct records in the second Combo Box.
Any help, suggestions, and recommendations are more than welcome.
Thanks
Dom
Tables
tblEmployees
eid – (employee ID) Autonumber – PK
fName (first name
Lname (last name)
annDate (anniversary date)
More fields, etc.
tblHolidays
hid (holiday ID) Autonumber – PK
hDate (holiday date
hName (holiday description)
so (standard or optional)
tblHolHrs
hhid (holiday hours ID) Autonumber – PK
eid (employee ID)
hDateT (date taken)
hHrs (holiday hours taken)
hid (holiday ID)
Form
frmEmpHolidays
Has two combo Boxes
Combo Box One:
Combo58 – unbound used to select appropriate employee
(row source) SELECT tblEmployees.eid, [lname] & ', ' & [fname] AS Employee, tblEmployees.annDate
FROM tblEmployees
ORDER BY [lname] & ', ' & [fname];
ColumnCount: 3
ColumnWidths: 0";1";0”
LimitToList: Yes
Events: After Update
Private Sub Combo58_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmEmpHolidays"
stLinkCriteria = "tblHolHrs.[eid] =" & Me!Combo58 & ""
DoCmd.OpenForm stDocName, , , stLinkCriteria
Combo36.Requery
End Sub
Combo box Two:
Combo36 – bound used to display all the holidays Dates and Descriptions)
(control source) hid
(row source) SELECT tblHolidays.hid, tblHolidays.hDate, tblHolidays.hName, tblHolHrs.eid
FROM tblEmployees INNER JOIN (tblHolidays INNER JOIN tblHolHrs ON tblHolidays.hid = tblHolHrs.hid) ON tblEmployees.eid = tblHolHrs.eid
WHERE (((tblHolHrs.eid)=[Forms]![frmEmpHolidays]![Combo58].Column(3)))
ORDER BY tblHolidays.hDate;
ColumnCount: 4
ColumnWidths: 0";0.75";2";0"
LimitToList: Yes
Events: Got Focus
Private Sub Combo36_GotFocus()
If Len(Trim(Nz(Combo58, ""
& ""
) = 0 Then
MsgBox "Please Select Employee First"
Combo58.SetFocus
Else
Combo36.Requery
End If
End Sub
I am out of ideas so I am turning to the experts for help.
What I need to do is select an employee from a combo box (Combo58) and then have another combo box (Combo36) only display holidays with a holiday date greater than or equal to the selected employee’s anniversary date (annDate)
I seem to have much of this worked out except the WHERE clause. I simply do not know how to select the correct records in the second Combo Box.
Any help, suggestions, and recommendations are more than welcome.
Thanks
Dom
Tables
tblEmployees
eid – (employee ID) Autonumber – PK
fName (first name
Lname (last name)
annDate (anniversary date)
More fields, etc.
tblHolidays
hid (holiday ID) Autonumber – PK
hDate (holiday date
hName (holiday description)
so (standard or optional)
tblHolHrs
hhid (holiday hours ID) Autonumber – PK
eid (employee ID)
hDateT (date taken)
hHrs (holiday hours taken)
hid (holiday ID)
Form
frmEmpHolidays
Has two combo Boxes
Combo Box One:
Combo58 – unbound used to select appropriate employee
(row source) SELECT tblEmployees.eid, [lname] & ', ' & [fname] AS Employee, tblEmployees.annDate
FROM tblEmployees
ORDER BY [lname] & ', ' & [fname];
ColumnCount: 3
ColumnWidths: 0";1";0”
LimitToList: Yes
Events: After Update
Private Sub Combo58_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmEmpHolidays"
stLinkCriteria = "tblHolHrs.[eid] =" & Me!Combo58 & ""
DoCmd.OpenForm stDocName, , , stLinkCriteria
Combo36.Requery
End Sub
Combo box Two:
Combo36 – bound used to display all the holidays Dates and Descriptions)
(control source) hid
(row source) SELECT tblHolidays.hid, tblHolidays.hDate, tblHolidays.hName, tblHolHrs.eid
FROM tblEmployees INNER JOIN (tblHolidays INNER JOIN tblHolHrs ON tblHolidays.hid = tblHolHrs.hid) ON tblEmployees.eid = tblHolHrs.eid
WHERE (((tblHolHrs.eid)=[Forms]![frmEmpHolidays]![Combo58].Column(3)))
ORDER BY tblHolidays.hDate;
ColumnCount: 4
ColumnWidths: 0";0.75";2";0"
LimitToList: Yes
Events: Got Focus
Private Sub Combo36_GotFocus()
If Len(Trim(Nz(Combo58, ""
MsgBox "Please Select Employee First"
Combo58.SetFocus
Else
Combo36.Requery
End If
End Sub