Calling a sub procedure

M

Mark

Hello All,

How do I call a sub procedure from a different form?

Here’s the setup: Form A has a button to open form B. Form A is still
open, but form B is on top. Once form B is updated I want to close form B,
but have it run a procedure from form A.

I know there are a few work around, like putting the code behind a txbox
then having it run on set focus, but I would prefer not to go this route.
 
M

Mark

That didn't work.

Here is what I tried.

forms!frMain.sbAlarmRefresh

and

frmain.sbAlarmRefresh

Both gave errors.
 
6

'69 Camaro

Hi, Mark.
How do I call a sub procedure from a different form?

Ensure that the other form is currently open and that the procedure is
public. Then call it from any other VBA code module with syntax such as the
following:

Forms!FormA.ProcedureName

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blog: http://DataDevilDog.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
6

'69 Camaro

Hi, Mark.
Here is what I tried.

forms!frMain.sbAlarmRefresh

and

frmain.sbAlarmRefresh

Both gave errors.

If the error message was "I've fallen and I can't get up," then say a prayer
and bury your database in a deep hole when it stops breathing. However, if
the error message was one of the other thousands of possibilities, then we
can probably help you troubleshoot what's wrong if you're willing to share
that secret message with us and post the declaration of your VBA procedure
that is being called.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blog: http://DataDevilDog.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
M

Mark

I thought maybe would could make a game out of it. Maybe call it guess the
error. :)

I posted the post below before I read your post about making the procedure
public. Once I change it to public it worked fine.

Thanks!
 
6

'69 Camaro

Hi, Mark.
I thought maybe would could make a game out of it. Maybe call it guess
the
error. :)

We play that game a lot around here. Some of us are fairly good at it!
I posted the post below before I read your post about making the procedure
public.

I suspect that means that next time you see a post written by '69 Camaro,
you'll make a point of reading it -- just in case it has some helpful info.
:)

You're welcome! Glad it helped!

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blog: http://DataDevilDog.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 

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