Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / March 2007

Tip: Looking for answers? Try searching our database.

Calling a sub procedure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark - 08 Mar 2007 19:17 GMT
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.
'69 Camaro - 08 Mar 2007 20:04 GMT
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.

> Hello All,
>
[quoted text clipped - 6 lines]
> 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.
'69 Camaro - 08 Mar 2007 21:52 GMT
Hi, Mark.

> Here is what I tried.
>
[quoted text clipped - 5 lines]
>
> 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.

> Hi, Mark.
>
[quoted text clipped - 26 lines]
>> 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.
Mark - 09 Mar 2007 14:01 GMT
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!

> Hi, Mark.
>
[quoted text clipped - 54 lines]
> >> 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.
'69 Camaro - 09 Mar 2007 17:08 GMT
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.
:-)

> Thanks!

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.

>I thought maybe would could make a game out of it.  Maybe call it guess the
> error. :)
[quoted text clipped - 73 lines]
>> >> then having it run on set focus, but I would prefer not to go this
>> >> route.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.