I've got some code as follows
****************************************************
Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Lead_Partner) And IsNull(Me.Details_Descriptions) Then
MsgBox "Please enter the Lead Partner's name and some information in the Details and Descriptions field"
Cancel = True 'stops the save command from running
Me.Lead_Partner.SetFocus
ElseIf IsNull(Me.Lead_Partner) And Not IsNull(Me.Details_Descriptions) Then
MsgBox "Please enter a Lead Partner's Name"
Cancel = True
Me.Lead_Partner.SetFocus
ElseIf IsNull(Me.Details_Descriptions) And Not IsNull(Me.Lead_Partner) Then
MsgBox "Please enter some Details/Descriptions about the Activity"
Cancel = True
Me.Details_Descriptions.SetFocus
Else: DoCmd.RunMacro ("Last Modified")
End If
End Sub
****************************************************
which needs to be applied to every form on my database.
Is it better to put this code in a module and then call it from the before update event of each form? If so, i would be grateful if someone could tell me what modifications (if any) need to be made to the code, and what exactly I need to write to call it - I have been experimenting all morning and cannot crack it!
Thanks
G
****************************************************
Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Lead_Partner) And IsNull(Me.Details_Descriptions) Then
MsgBox "Please enter the Lead Partner's name and some information in the Details and Descriptions field"
Cancel = True 'stops the save command from running
Me.Lead_Partner.SetFocus
ElseIf IsNull(Me.Lead_Partner) And Not IsNull(Me.Details_Descriptions) Then
MsgBox "Please enter a Lead Partner's Name"
Cancel = True
Me.Lead_Partner.SetFocus
ElseIf IsNull(Me.Details_Descriptions) And Not IsNull(Me.Lead_Partner) Then
MsgBox "Please enter some Details/Descriptions about the Activity"
Cancel = True
Me.Details_Descriptions.SetFocus
Else: DoCmd.RunMacro ("Last Modified")
End If
End Sub
****************************************************
which needs to be applied to every form on my database.
Is it better to put this code in a module and then call it from the before update event of each form? If so, i would be grateful if someone could tell me what modifications (if any) need to be made to the code, and what exactly I need to write to call it - I have been experimenting all morning and cannot crack it!
Thanks
G