Call module/procedure

I

Igor G.

I have many forms (about 50) with the same code.
How to call this code from module or prodedure?
Thanks!

Here is code:
--------------------------------
Private Sub Form_Current()
If CurrentProject.AllForms("GLAVNI_IZBORNIK").IsLoaded Then
Me.AllowEdits = True
Me.AllowDeletions = True
If Me.Datum <= Date - 1 Then
Me.AllowEdits = False
Me.AllowDeletions = False
Else
End If
If CurrentProject.AllForms("CheckMenu").IsLoaded Then
If [Forms]![CheckMenu]![chkEditOk] Then
Me.AllowEdits = True
Me.AllowDeletions = True
End If
End If
End If
End Sub
 
D

davidp

Igor G. said:
I have many forms (about 50) with the same code.
How to call this code from module or prodedure?
Thanks!

Here is code:
--------------------------------
Private Sub Form_Current()
If CurrentProject.AllForms("GLAVNI_IZBORNIK").IsLoaded Then
Me.AllowEdits = True
Me.AllowDeletions = True
If Me.Datum <= Date - 1 Then
Me.AllowEdits = False
Me.AllowDeletions = False
Else
End If
If CurrentProject.AllForms("CheckMenu").IsLoaded Then
If [Forms]![CheckMenu]![chkEditOk] Then
Me.AllowEdits = True
Me.AllowDeletions = True
End If
End If
End If
End Sub

Need to change this to a function and place it a module. That way its
available to entire application.
 
O

Ofer Cohen

Create a function in a module that accept the form name

Function Run_Form_Current(MyFormName As String)
If CurrentProject.AllForms("GLAVNI_IZBORNIK").IsLoaded Then
Forms(MyFormName).AllowEdits = True
Forms(MyFormName).AllowDeletions = True
If Forms(MyFormName).Datum <= Date - 1 Then
Forms(MyFormName).AllowEdits = False
Forms(MyFormName).AllowDeletions = False
Else
End If
If CurrentProject.AllForms("CheckMenu").IsLoaded Then
If [Forms]![CheckMenu]![chkEditOk] Then
Forms(MyFormName).AllowEdits = True
Forms(MyFormName).AllowDeletions = True
End If
End If
End If
End Sub
======================
To Call this function from the Form current, you can use

Run_Form_Current Me.Name
 
Top