Need to Hide command button

G

Guest

I have a form for each user that shows only data that pertains to them. They
click a "SEARCH" command button that opens a search form I created for all
users.

On the search form I have a different command button for each user that
returns them to their previous screen. I only want the command button that
pertains to this user to be visible. Is there a way to code the "ON CURRENT"
event of the search form to hide the other command buttons based on which
user form caused the search form to open?
 
K

Ken Snell [MVP]

Yes, if you give us more information, we could help. But, you could get
around this entirely by one of two methods:

(1) Open the search form in Dialog mode, so that the user must close it to
return to the previous screen. Don't close the form that has the "SEARCH"
button on it when you open the Search form. That way, the button on the
Search form just needs to close the Search form.

(2) Pass the name of the "calling" form to the Search form using the
OpenArgs argument of the DoCmd.OpenForm action. Then in the "Close" event of
the Search form, just open the form whose name is the same as what's in the
OpenArgs value of the Search form.
 
J

John Vinson

I have a form for each user that shows only data that pertains to them. They
click a "SEARCH" command button that opens a search form I created for all
users.

On the search form I have a different command button for each user that
returns them to their previous screen. I only want the command button that
pertains to this user to be visible. Is there a way to code the "ON CURRENT"
event of the search form to hide the other command buttons based on which
user form caused the search form to open?

I've got a different suggestion which may be simpler: use ONE button
to return, for all users; and pass the name of the calling form in the
OpenArgs argument of the OpenForm method.

For that matter... why not just close the Search form? If the calling
form is still open, it will resume the focus.

All that said... yes, you can use the Current event of the search form
to set the Visible property of any control to False or True as needed.
Again, you can pass the name of the calling form in OpenArgs.

John W. Vinson[MVP]
 

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