A
Alias
Hello all,
I have a few lines of code that I use in several different combo boxes.
Since the code does the same thing regardless of where it's used it has
become redundant.
The code checks if the current record is a new record, then checks if the
value of a combo box is null. If both are true it executes an Undo action
from the OnExit property.
I would like to have the following code in it's own Sub or Function and then
call that Sub or Function from other modules when I need to use it. Can
anyone show me how to do this?
Here's the code:
Dim intnewrec As Integer
intnewrec = Form.NewRecord
If intnewrec = True And IsNull(Me.cboEmp_Name.Value) Then
MsgBox "Employee field cannot be left blank."
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdUndo
DoCmd.SetWarnings True
End If
I have a few lines of code that I use in several different combo boxes.
Since the code does the same thing regardless of where it's used it has
become redundant.
The code checks if the current record is a new record, then checks if the
value of a combo box is null. If both are true it executes an Undo action
from the OnExit property.
I would like to have the following code in it's own Sub or Function and then
call that Sub or Function from other modules when I need to use it. Can
anyone show me how to do this?
Here's the code:
Dim intnewrec As Integer
intnewrec = Form.NewRecord
If intnewrec = True And IsNull(Me.cboEmp_Name.Value) Then
MsgBox "Employee field cannot be left blank."
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdUndo
DoCmd.SetWarnings True
End If