Clicking button on hidden form with VBA

MikeAngelastro

Registered User.
Local time
Today, 03:04
Joined
Mar 3, 2000
Messages
254
Hi,

I have an Access app that opens a form in hidden mode. I am able with code to get the values contained in the textboxes of the form. I am able to select items in a listbox on the hidden form. However, the hidden form contains a button that I want to "click" using VBA code. I am expecting that the event handling code behind a hidden form to act as a method of the form. The line of code I use to try to run the code behind the command button is:

[Forms]![ySales Order Item Information].OKButton_Click

When I run this line of code I get an error number 2465 - Application-defined or Object-defined error.

Any body know what I'm doing wrong? I have a feeling that this should work.

Thanks,

Mike
 
Instead of having the code in a form module, have the code stored in a module, passing whatever parameters you need, then reference the code from the OnClick event on the form? That would allow the code to be accessed from other objects.
 
Thanks pdx_man.

After reading your suggestion, I took another look at the code behind the command button. Then it hit me. The sub was private. That was why it didn't work. When I made it public, my code worked.

Thanks again!

Mike
 

Users who are viewing this thread

Back
Top Bottom