Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically Click a Button

Status
Not open for further replies.

supervi

MIS
Mar 22, 2003
61
CA
I have this code that opens up another form. I also want it to automatically click a button on that form when its open.



DoCmd.OpenForm "Annual Load Follow", , , X

----
DoCmd.Automatically.click.button221
----

I know thats not going to work but you get the idea

Any ideas on how i would do this?

Thanks
 
Hello,

In the LOAD event of the form that you open
try :

Code:
call cmdButtonIwantToClick_Click

it will simulate the click action.

Hope it helps

SG
 
This will happen every time the form is opened right? i just want it to happen when the user triggers this event. Know what i am saying?
 
Then on your button, use vba to read the same as Rick suggested. This will call it only after loading the form using the button on your other form.



Ascii dumb question, get a dumb Ansi
 
Hey Rick i found a way to use that code, but i get an error stating that it can't move the focus to my subform. My subform it not invisible.

 
I keep getting an error stating that it can't focus on my subform.

 
Hi,

As I get it, your button is on a SubForm...
if it is so, you will only be able to 'call'
the code from it if it is public as in

Code:
Public sub cmdButton_click()
...

Then you would call it by doing

Code:
   call Forms("SubFormName").cmdButton_click

That should do the trick!


SG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top