Josh
Do the parents know that Sally and Jim are room mates? ;-)
I think what you are saying is that after asiging Sally to Jim's room, you want to automatically update Sally's record to reflect that Jim is her roommate??
I suspect the simplest way is to use the DoCmd.RunSQL method.
Assumptions:
- The room mate field uses a combo box where the record sourse is [tt]
SELECT Registration.RecNumber, [First name],[last Name] AS [Full name] FROM Registration[/tt]
- RecNumber is numeric (long)
- The name of the Room Mate field is RooMateRec
For the AfterUpdate event for the room mate field.
Code:
Dim strSQL as String
If Nz(Me.RoomMateRec, 0) > 0 Then
strSQL = "UPDATE Registration SET RoomMateRec = " _
& Me.RecNumber & " WHERE RecNumber = " & RoomMateRec
DoCmd.SetWarnings (False) 'turn off wanring prompt
DoCmd.RunSQL strSQL
DoCmd.SetWarnings (True) 'turn warnings back on
End If
Okay, that is one answer. Now something to ponder. What happens is Sally does not want to be Jim's room mate?? Let's say, she want to bunk up with a school friend, Betty Anne. Hmmm, now you have to adjust Jim's record, Sally's record and Betty Anne's record. Now, let's make it more complicated. Betty's registration was handled by some one else - this data entry person updated Betty's record and Sally's record without even knowing about Jim!! But Jim will have receive a confirmation letter saying he is bunking with Sally, Betty will receive a letter indicating that she bunking with Sally, and poor Sally will receive two letters that she is bunking with both Sally and Jim!
This makes
All In The Family look tame.
When you start this type maintenance and integrity issues, start thinking abour re-evaluating your design.
I suspect you may have more success by assining registrants to "beds", where a room mate is assigned bed in the same room. NOW, if you receive conflicting bunk mates, you are dealing with the issue at the room / bed level where conflicts will be less likely.
Your design is still very workable, but you may have to figure out a process to prevent poor Sally from being assigned different bunk mates. ;-)
Richard