Running a public sub on one form from another

A

Adam Thwaites

Hi, I have two forms, Form1 and Form2. Form1 contains a Public Sub called
PublicSub1 which I want to run from a click event on Form2. Is this possible?
--
Adam Thwaites
Access Database Designer
adam.*spamless*[email protected]
Manchester, UK
(I have no access to other sites apart from microsoft.com so posting
external links is no use to me)
 
O

Ofer

You can use

Form_FormName.SubName
============================
Bou you should create a function in a module that include the code from the
sub in form1, and call this function from both sub
 
A

Adam Thwaites

Excellent, thanks.
How does Form_FormName differ from [Forms]![FormName]
--
Adam Thwaites
Access Database Designer
adam.*spamless*[email protected]
Manchester, UK
(I have no access to other sites apart from microsoft.com so posting
external links is no use to me)
 
D

Douglas J Steele

I believe that the first refers to the form's Class (i.e.: the module that
contains the code), while the latter refers to the form itself.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Adam Thwaites said:
Excellent, thanks.
How does Form_FormName differ from [Forms]![FormName]
--
Adam Thwaites
Access Database Designer
adam.*spamless*[email protected]
Manchester, UK
(I have no access to other sites apart from microsoft.com so posting
external links is no use to me)


Ofer said:
You can use

Form_FormName.SubName
============================
Bou you should create a function in a module that include the code from the
sub in form1, and call this function from both sub
 

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