Compile Error: sub or Function not Defined

G

Guest

Hi
I seem to be getting this error when I call a sub defined in one form from
code in another form but I can't work out why.

The first form has two list boxes with the idea being that the user can add
items from one to the other either by slecting fields individually or by
selecting a saved 'set' of items. The sub (ExcludeFromFieldList) is declared
as public in the first form and simply removes items from the first list that
appear in the second. The second form is essentially a pop up that allows
the user to select a saved set of items. Once the selection is made the
second list box display the set of items and I want to be able to call the
above procedure to remove the items from the first list box.

I guess I can move the procedure into a module (as opposed to a form module)
but as far as I am aware this ought to work.

Thanks in advance
 
A

Andi Mayer

Hi
I seem to be getting this error when I call a sub defined in one form from
code in another form but I can't work out why.

The first form has two list boxes with the idea being that the user can add
items from one to the other either by slecting fields individually or by
selecting a saved 'set' of items. The sub (ExcludeFromFieldList) is declared
as public in the first form and simply removes items from the first list that
appear in the second. The second form is essentially a pop up that allows
the user to select a saved set of items. Once the selection is made the
second list box display the set of items and I want to be able to call the
above procedure to remove the items from the first list box.

I guess I can move the procedure into a module (as opposed to a form module)
but as far as I am aware this ought to work.

Thanks in advance

how do you call this sub?
 
G

Guest

Hi Andi

I have tried all of the following:
ExcludeFromFieldList
Call ExcludeFromFieldList
Call ExcludeFromFieldList()

BTW, the sub is defined as:
Public Sub ExludeFromFieldList()
...
End Sub

Andy
 
A

Andi Mayer

Hi Andi

I have tried all of the following:
ExcludeFromFieldList
Call ExcludeFromFieldList
Call ExcludeFromFieldList()

BTW, the sub is defined as:
Public Sub ExludeFromFieldList()
...
End Sub

There is the problem:
a Form module is a class-Module, therefore you have write:

Forms("MyFormName").ExludeFromFieldList
 
G

Guest

That's worked! Thanks very much.

Andy

Andi Mayer said:
There is the problem:
a Form module is a class-Module, therefore you have write:

Forms("MyFormName").ExludeFromFieldList
 

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