Call module/procedure

G

Guest

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
 
G

Guest

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

AllowEdits=False issue 3
Locking a record via a form 2
Mandatory Fields 4
Help explain to me 3
Locking a record 2
Can't get code to run 3
multiple criteria in dlookup 6
Locked out of fields in Access 2000 11

Top