Possible to run a procedure in another open form?

Possible to run a procedure in another open form?

am 22.01.2008 21:31:32 von PW

Hi,

Is it possible to run a procedure/subroutine in an open form from
another open form? I assume the procedure would have to be public but
maybe not.

If so, what would be the syntax?

Thanks! Am using Access 2003.

-paulw

Re: Possible to run a procedure in another open form?

am 23.01.2008 00:06:19 von Stuart McCall

"PW" wrote in message
news:9ikcp3lft1da3vmu1sngp94kr8g2r1bb3d@4ax.com...
> Hi,
>
> Is it possible to run a procedure/subroutine in an open form from
> another open form? I assume the procedure would have to be public but
> maybe not.
>
> If so, what would be the syntax?
>
> Thanks! Am using Access 2003.
>
> -paulw

You assume correctly. Make the proc public, then call it like this:

Form_MyFormName.PublicProc

Re: Possible to run a procedure in another open form?

am 23.01.2008 00:41:30 von fredg

On Tue, 22 Jan 2008 13:31:32 -0700, PW wrote:

> Hi,
>
> Is it possible to run a procedure/subroutine in an open form from
> another open form? I assume the procedure would have to be public but
> maybe not.
>
> If so, what would be the syntax?
>
> Thanks! Am using Access 2003.
>
> -paulw

Let's assume you wish to call a command button's click event on one
form from another form.

Call Forms("NameOfForm").CommandName_Click

Make sure the sub procedure is set to Public.
Both forms must be open.

Change "NameOfForm" and CommandName_Click
to whatever the actual form and sub procedure names are.


--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Re: Possible to run a procedure in another open form?

am 23.01.2008 01:29:45 von Larry Linson

"PW" wrote

> Is it possible to run a procedure/subroutine in an
> open form from another open form? I assume the
> procedure would have to be public but maybe not.

A "procedure in another form" is, in fact, a "method in a class module".
Thus, "maybe not", indeed.

> If so, what would be the syntax?

Scenario: A Form (name immaterial) calls a Sub procedure in a Form named
"frmAProcIsHere" in the following Click event procedure:

Private Sub cmdExecuteIt_Click()
Forms!frmAProcIsHere.InsertString Me
End Sub

Note that the Form frmAProcIsHere must be open to be in the Forms collection
and be accessible.

To execute the procedure, defined in the General section of the module of
form "frmAProcIsHere".

Sub InsertString(frm As Form)
frm!txtFillMe = "Filled on " & Date
End Sub

for the procedure in "frmAProcIsHere" to insert a text string in a Control
on the the form containg the calling code. Note that the Sub is not defined
as Public. (If you wish, try to do so.)

> Thanks! Am using Access 2003.

The example from which the code is copied is in Access 2003.

Larry Linson
Microsoft Access MVP

Re: Possible to run a procedure in another open form?

am 23.01.2008 04:15:12 von PW

On Tue, 22 Jan 2008 15:41:30 -0800, fredg
wrote:

>On Tue, 22 Jan 2008 13:31:32 -0700, PW wrote:
>
>> Hi,
>>
>> Is it possible to run a procedure/subroutine in an open form from
>> another open form? I assume the procedure would have to be public but
>> maybe not.
>>
>> If so, what would be the syntax?
>>
>> Thanks! Am using Access 2003.
>>
>> -paulw
>
>Let's assume you wish to call a command button's click event on one
>form from another form.

Exactly what I want to do.

>
>Call Forms("NameOfForm").CommandName_Click
>
>Make sure the sub procedure is set to Public.
>Both forms must be open.
>
>Change "NameOfForm" and CommandName_Click
>to whatever the actual form and sub procedure names are.


That did it you Fredg-ster!:-) Thanks!

-paulw

Re: Possible to run a procedure in another open form?

am 23.01.2008 04:15:41 von PW

On Tue, 22 Jan 2008 23:06:19 -0000, "Stuart McCall"
wrote:

>"PW" wrote in message
>news:9ikcp3lft1da3vmu1sngp94kr8g2r1bb3d@4ax.com...
>> Hi,
>>
>> Is it possible to run a procedure/subroutine in an open form from
>> another open form? I assume the procedure would have to be public but
>> maybe not.
>>
>> If so, what would be the syntax?
>>
>> Thanks! Am using Access 2003.
>>
>> -paulw
>
>You assume correctly. Make the proc public, then call it like this:
>
>Form_MyFormName.PublicProc
>

Thank you Stuart!

-paulw

Re: Possible to run a procedure in another open form?

am 23.01.2008 04:16:57 von PW

On Wed, 23 Jan 2008 00:29:45 GMT, "Larry Linson"
wrote:

>"PW" wrote
>
> > Is it possible to run a procedure/subroutine in an
> > open form from another open form? I assume the
> > procedure would have to be public but maybe not.
>
>A "procedure in another form" is, in fact, a "method in a class module".

I need to learn more about classes in Access 2003. I have done a lot
of OOP in Visual FoxPro and would like to see what is available in
Access. Any recommendations?

>Thus, "maybe not", indeed.
>
> > If so, what would be the syntax?
>
>Scenario: A Form (name immaterial) calls a Sub procedure in a Form named
>"frmAProcIsHere" in the following Click event procedure:
>
> Private Sub cmdExecuteIt_Click()
> Forms!frmAProcIsHere.InsertString Me
> End Sub
>
>Note that the Form frmAProcIsHere must be open to be in the Forms collection
>and be accessible.
>
>To execute the procedure, defined in the General section of the module of
>form "frmAProcIsHere".
>
> Sub InsertString(frm As Form)
> frm!txtFillMe = "Filled on " & Date
> End Sub
>
>for the procedure in "frmAProcIsHere" to insert a text string in a Control
>on the the form containg the calling code. Note that the Sub is not defined
>as Public. (If you wish, try to do so.)
>
> > Thanks! Am using Access 2003.
>
>The example from which the code is copied is in Access 2003.
>
> Larry Linson
> Microsoft Access MVP
>

Thanks for the lesson Larry!

-paul

Re: Possible to run a procedure in another open form?

am 26.01.2008 01:12:40 von PleaseNOOOsPAMMkallal

"PW" wrote in message

>>A "procedure in another form" is, in fact, a "method in a class module".
>
> I need to learn more about classes in Access 2003. I have done a lot
> of OOP in Visual FoxPro and would like to see what is available in
> Access. Any recommendations?


I give some ideas here:
http://www.members.shaw.ca/AlbertKallal/Articles/WhyClass.ht ml


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com