Refering to Form controls in a general module

I

Imran J Khan

Using information from similar questions in this forum, I am trying to create
a stand alone module in a library db that can be called from a large number
of forms in a second db (they reside on the same disk and several similar
subs have been in use).
The forms are essentially identical, and need to disable a date field unless
the ntUser is same as the 'taskedby' and that is the same as 'taskedto'.
I prefer to have a single stand alone module to make house keeping simple.
The following is my stand alone module:
Option Compare Database
Option Explicit

Public Sub setTogglePlannedDateControl(WhatForm As Form)
If (Nz(WhatForm.taskedBy, "") <> "") Then
If (WhatForm.taskedBy = getCurrentUser) And (WhatForm.taskedBy <>
WhatForm.taskedTo) Then
WhatForm.dueDate.Locked = True
End If
End If
End Sub

And the following is the event procedure call I am trying to use:

setTogglePlannedDateControl Me

error msg:Compile error Sub or Function Not Defined

I have also tried the following:

setTogglePlannedDateControl (Me)
setTogglePlannedDateControl (Me.Form.Name)
setTogglePlannedDateControl (Form1)

Imran.
 
D

Douglas J. Steele

You're sure you haven't mistyped the name somewhere?

If you named the module setTogglePlannedDateControl, rename it: modules
cannot have the same name as routines within modules.

If neither of those are the issue, try

Call setTogglePlannedDateControl (Me)
 
I

Imran J Khan

Thanks for letting me know it should work. There were no misspellings and I
had named the module and routine differently (msetToggle..). I created the
module in the same db as the form and the error did not show up (I don't have
enough data to test the actual function right now).
So now a follow up question... Since I prefer to keep house keeping simple,
and currently most 'shared' modules are in a library.mdb file where other
..mdb can call them, how do I get this module to work like that. Or am I
mistaken in thinking .mdb files can call modules from other .mdb on the same
folder?
Imran
 

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

Top