This is a confusing database. If you understand it, great. It took me over 3 hours to kind of understand what was going on.
IF I understood what you want, then this should work.
Open the database. Make sure that all objects are closed.
Type <ctl> G (hold the control key down and press the letter G)
In the left pane of the IDE, double click on "Form_ATTENDSUBFORM"
Paste in the following
Code:
Private Sub cboday_AfterUpdate()
Dim r As DAO.Recordset
Dim ssQL As String
ssQL = "SELECT TOP 1 LABOURWAGE.WAGE, LABOUR.LABOURTYPE, LABOURWAGE.WAGEDATE"
ssQL = ssQL & " FROM LABOUR RIGHT JOIN LABOURWAGE ON LABOUR.LBID = LABOURWAGE.LBID"
ssQL = ssQL & " WHERE LABOUR.LABOURTYPE = '" & Me.Parent.[TYPE] & "'"
ssQL = ssQL & " AND LABOURWAGE.WAGEDATE <= #" & Me.cboday & "#"
ssQL = ssQL & " ORDER BY LABOURWAGE.WAGEDATE DESC;"
' Debug.Print ssQL
'open recordset
Set r = CurrentDb.OpenRecordset(ssQL)
'check for records
If r.BOF And r.EOF Then
' no record
Me.WAGERATE = 0
Else
' found record
Me.WAGERATE = r("Wage")
End If
r.Close
Set r = Nothing
Me.Requery
End Sub
In the debug menu, Select "Compile Database"
Close the IDE
Close any objects visible.
Open the form "ATTENDFORM"
Select a month, then add an "attenddate".
PS: "Type" is a reserved word in Access and shouldn't be used as an object name. See
http://allenbrowne.com/AppIssueBadWord.html
You are using an autonumber as the employee id number. An autonumber should never be displayed or used as meaningful data.
See
http://www.utteraccess.com/wiki/index.php/Autonumbers
After you have read the page, at the bottom of the page, note #1 and #3