Need code to press a button after un hiding form

S

Sierras

Anyone have code that will press a button on a form after it is
un-hidden?

I basically have a filter button on a form that I would like to
execute after the form becomes visible. Reason being that when a user
creates a new record, I hide the main form and open a data entry form.
When the data entry form closes, the main form becomes visible again.
The problem is that the record that the user just entered does not
show up until the filter button is pressed again (if the new record
meets the filter criteria, that is). So I would like to have it done
automatically every time the form becomes visible.

Thanks...
 
S

SteveM

To perform a button click you need to call the button's click event procedure.

Call myButton_Click

Two other options:
1. Close the main form instead of hiding it and re-open it when you close
the data-entry form.
2. Open the data-entry form as a Dialog. This will suspend the code in the
calling routine until the form is closed. Then you can requery your other
form.

Steve
 
S

Sierras

Thanks for the info.

I used to close the form instead of hiding it as you suggest in your
option 1. The problem was that when a user has already set up their
criteria filters, the filters would disappear when the form opened. So
to try and maintain the filters so they don't have to re-select them,
I hid the form when they were adding or modifying a record so that
they filter criteria was the same when they go back to the main form.

Thanks again...
 
S

Sierras

I'm having trouble making this work.

Forms!Form2.cmdButton_Click

I've but the code in the form2 on close event. But it's not working.
Any idea how to get the button on another form to click?

Thanks...
 
S

Sierras

OK - I found a way to get this to work. So I figure I'd put it here
in case anyone else was looking for a way to click a button on another
form with code.

Basically, I made the click event of the button I want to click on
Form1 a PUBLIC event and not a private event. That's half way there.

Then just added this code to close event of Form2.

Call Forms("Form1").cmdButton_Click

That's it. Very simple and works well. Good luck...
 

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