Make inactive

J

JenK

I would like to make a combo box and text box inactive after the user has
moved into the subform. How can I do this. I use both macros and expressions
so I am wide open to learning the best way to go about this.
 
R

Ryan

I tried the "On Lost Focus" of the main form, and the "On Got Focus" event of
the subform, but these didnt work. I was able to add the code below to the
"On Got Focus" event of one of the controls on the subform and it did disable
the textbox. Im not sure how your users can move to the subform, but if they
can acess every control you would have to add this code to every control.

Forms![YourMainFormName]![TheFieldToDisable].Enabled = False
 
L

Linq Adams via AccessMonster.com

A forms in Access can only utilize the "On Lost Focus" and "On Got Focus"
events when the have no controls that can receive focus, or if these controls
are all invisible.

A subform, although it holds a form, is actually a control of the main form,
and has both OnEnter and OnExit events tied to it. So you can put the code in
these events

Private Sub SubformControlName_Enter()
Me.MyTextBoxName.Enabled = False
Me.MyComboBoxName.Enabled = False
End Sub

Private Sub SubformControlName_Exit(Cancel As Integer)
Me.MyTextBoxName.Enabled = True
Me.MyComboBoxName.Enabled = True
End Sub
 
J

JenK

Thank-you for the answer, I am unsure though as to what field name I out in
exchange for MyTextBoxName (Me.MyTextBoxName.Enabled = False). I put
ProjectID in the MyComboBoxName.
 
R

Ryan

You would put the name of the textbox you want to disable. In your original
post you said you had a combo box and a textbox you want to disable. If your
unsure what the name is of the textbox just right click it, go to properties,
then the all tab, and the name of the textbox will be listed there.
 

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