Calling Private Sub()

  • Thread starter Thread starter Deanna
  • Start date Start date
D

Deanna

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
 
Deanna said:
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,
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
 
Deanna said:
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.
 
Back
Top