You are welcome Tom, but, I was ready to post:
No Tom! It's Ok!
I can open your file and now I did.
You have a "parent-child" relationship between StaffMemberIDpk and BackfillStaffMemberIDfk. That is clear.
Next you want to find if there is a record with the current StaffMemberIDpk in the BackfillStaffMemberIDfk field, and if there is, to display its StaffMemberIDpk in NewID textbox. Am I right?
If I am, i suggest you three ways.
1 -- With in Control Source Dlookup:
You keep in NewID the expression:
Code:
=DLookUp("StaffMemberIDpk","T01_StaffMembers","BackfillStaffMemberIDfk=" & Nz([cboStaffMembers],0))
2 -- With recordset in VBA:
Code:
Set rs = CurrentDb.OpenRecordset("SELECT T01_StaffMembers.StaffMemberIDpk FROM T01_StaffMembers " _
& "WHERE (((T01_StaffMembers.BackfillStaffMemberIDfk)=" _
& nz(Me.StaffMemberIDfk_Archive,0) & "));", dbOpenSnapshot)
Me.NewID = Null
If rs.RecordCount > 0 Then
Me.NewID = rs!StaffMemberIDpk
End If
3 -- With dlookup in VBA:
Code:
Me.NewID = DLookup("StaffMemberIDpk", "T01_StaffMembers", "BackfillStaffMemberIDfk=" & nz(Me.StaffMemberIDfk_Archive,0))
and as common for all ways in button's code:
Code:
If IsNull(Me.NewID) Then
MsgBox "No backfill assigned!"
Else
MsgBox "A backfill has been assigned!"
End If
So, I think that now I cover you.
Cheers,
John