Executing Multiple Event Procedures

Jideogu

New member
Local time
Today, 16:56
Joined
Jan 6, 2011
Messages
9
I have a form that is bound to table with the following fields:
[DateAssigned]
[Due]
[StaffA] Lookup field
[DateInfoRequested]
[DateInfoReceived]
[DateInfoAssigned]
[DateInfoDue]
[StaffB] Lookup field

What I want to accomplish is if [DateAssigned] is updated, you must select the assigned staff from [StaffA] list. When [Date InfoAssigned] is updated, you must select the assigned staff from [StaffB] list. [DateAssigned] and [DateInfoAssigned] may be null or not null. However, whenever any of these Date Assigned fields are updated, I want it to force the user to select the assigned staff with the staff set focus.

I would really appreciate a code that will enable me to accomplish this in the Before Update Event I suppose.

Your assistance is deeply appreciated.
 
Re: Executing Multiple Event Procedures in Access 2007

This this the code that I've tried. The first part works perfectly. However, once I add the second part, it stops working. I am still new to this and will appreciate any assistance that anyone can offer.

Thanks.

Private Sub Form_BeforeUpdate(Cancel As Integer)

If IsDate(Me.[ DateAssigned]) And IsNull(Me.[ StaffA]) Then
Cancel = True ' Stop the save action
MsgBox "When you Assign a case, you must assign it to a Sraff Member. Please select a Staff member from list."
Me.StaffA.SetFocus
End If
If IsDate(Me.[ DateInfoAssigned]) And IsNull(Me.[ StaffB]) Then
Cancel = True ' Stop the save action
MsgBox "When you Assign a case, you must assign it to a Staff Member. Please select a Staff Member from list."
Me.StaffB.SetFocus
End If
 
You did quite well to come up with that. The first one should be:
Code:
If [COLOR=Blue]Not [/COLOR]IsDate(Me.[DateAssigned]) And IsNull(Me.[StaffA]) Then
    Cancel = True ' Stop the save action
    MsgBox "When you Assign a case, you must assign it to a Sraff Member. Please select a Staff member from list."
    Me.StaffA.SetFocus
[COLOR=Blue]    Exit Function[/COLOR]
End If
I've highlighted the bits I added. Add it to the second block.
 
Thank you very much for the prompt response. I've adjusted the code as you suggested. However, I receive an error message: Compile Error: "Exit Function Not Allowed in Sub or Property" With Exit Function highlighted. When I click OK, it highlights "Private Sub Form_BeforeUpdate(Cancel As Integer)" as well.

How can I resolve this?
 
Thank you very much. That did it.

Have a happy holidays.
 

Users who are viewing this thread

Back
Top Bottom