Creating a command button that can only b used by a specific item

R

Rick

How do you create a command button that opens up a form that can only be
opened up when it meets a specific type of project category. I want the
command button to only open the form when I want to enter data into another
table that contains data only for that type of project.
 
S

Sprinks

Rick,

Presuming that the Project Category is bound to a control on your form, one
way is to disable the button by default and enable it when the category has
the special value:

If Me![txtProjectCategory] = YourValue Then
Me![YourCommandButton].Enabled = True
Else
Me![YourCommandButton].Enabled = False
End If

Place the code in the Project Category AfterUpdate event and the form's
OnCurrent event.

Alternatively, you could make the decision in the button's OnClick procedure:

If Me![txtProjectCategory] = YourValue Then
...open form here
Else
MsgBox "This form only applies when Project Category equals 5."
End If

Hope that helps.
Sprinks
 
Top