Visible/Invisible based on form status

T

Tara

I have a form that I use in 2 ways in my database. On this form I have a
command button used to find clients by last name. Depending on how the form
is opened, I want the command button to be either visible or invisible. In
one instance the form is called in order to add a new record. In this
circumstance, it's set to open to a new record and only allows additions.
Existing records cannot be accessed. I would like the command button to be
invisible when the form opens in this state. In the other instance, the
form is used to view/edit existing records and is set to open to view all
records. I'd like the command button to be visible when the form opens this
way. I assume I need to start the coding process by creating a standalone
procedure and then calling the procedure at the appropriate time. But I'm
not sure how to code the standalone procedure.

Thanks!

Tara
 
P

Paolo

Hi Tara,

when you open your form use an openargs for example "add" if you open form
add a record or "view" if you open for view/edit.
On the open event of your form add this code

if me.openargs="add" then
yourbutton.visible=false
elseif me.openargs="view" then
yourbutton.visible=true
endif

this is aircode so you have to test it.

HTH Paolo
 
T

Tara

Thanks for the suggestion Paolo. I tried it, but unfortunately, it didn't
work. Do you have any other suggestions?
 
P

Paolo

Tara, how do you open the form where the button is?
If you open the form using the docmd.openform command the openargs trick
will work. Otherwise tell me how do you open it so I'll be able to give you
other suggestion.

Regards Paolo
 

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