PC Review


Reply
Thread Tools Rate Thread

Calling Private Sub()

 
 
Deanna
Guest
Posts: n/a
 
      6th May 2010
I have two seperate forms (frmA, frmB). I have a command button on frmA that
when clicked should click a command button on frmB. I am using a Call to do
this but keep getting a message: application-defined or object-defined error.
I have tweaked my code to match other Q&A solutions here but I still can't
get this to work. Any thoughts?

Call Forms("frmB").Command229_Click
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      6th May 2010
"Deanna" <(E-Mail Removed)> wrote in message
news:4F49ABBA-69A2-4E84-9AA7-(E-Mail Removed)...
>I have two seperate forms (frmA, frmB). I have a command button on frmA
>that
> when clicked should click a command button on frmB. I am using a Call to
> do
> this but keep getting a message: application-defined or object-defined
> error.
> I have tweaked my code to match other Q&A solutions here but I still can't
> get this to work. Any thoughts?
>
> Call Forms("frmB").Command229_Click



1. You need to make sure that Comand229_Click is defined in frmB as a Public
Sub, not Private.

2. frmB must be open when you call the Sub.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
 
Deanna
Guest
Posts: n/a
 
      6th May 2010
Dirk,
As you suspected Command229_Click is Private sub. What are the steps needed
to change this to Public and are there (I'm assuming yes) ramifications to
doing this?
Deanna

"Dirk Goldgar" wrote:

> "Deanna" <(E-Mail Removed)> wrote in message
> news:4F49ABBA-69A2-4E84-9AA7-(E-Mail Removed)...
> >I have two seperate forms (frmA, frmB). I have a command button on frmA
> >that
> > when clicked should click a command button on frmB. I am using a Call to
> > do
> > this but keep getting a message: application-defined or object-defined
> > error.
> > I have tweaked my code to match other Q&A solutions here but I still can't
> > get this to work. Any thoughts?
> >
> > Call Forms("frmB").Command229_Click

>
>
> 1. You need to make sure that Comand229_Click is defined in frmB as a Public
> Sub, not Private.
>
> 2. frmB must be open when you call the Sub.
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
>

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      6th May 2010
"Deanna" <(E-Mail Removed)> wrote in message
news:946E4A9F-33C3-476E-A863-(E-Mail Removed)...
> Dirk,
> As you suspected Command229_Click is Private sub. What are the steps
> needed
> to change this to Public and are there (I'm assuming yes) ramifications to
> doing this?


No ramifications. Just open the form in design view, go to the form's
module and change the line:

Private Sub Command229_Click()

to:

Public Sub Command229_Click()

Recompile and save.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Improve method of calling a private function in a private module XP Microsoft Excel Programming 1 30th Apr 2008 06:41 PM
Calling a private macro =?Utf-8?B?TmljayBTbWl0aA==?= Microsoft Excel Programming 5 8th Jun 2006 12:03 PM
Calling a Private Sub =?Utf-8?B?YmVu?= Microsoft Excel Programming 8 8th Dec 2004 10:18 PM
Re: Calling a private sub Bob Phillips Microsoft Excel Programming 3 29th Jul 2004 02:59 AM
Calling private sub from different form Simon Microsoft Access Forms 3 10th Jun 2004 04:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:22 PM.