Calling Private Sub()

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
 
D

Dirk Goldgar

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.
 
D

Deanna

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
 
D

Dirk Goldgar

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.
 

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