disabling controls on a subform

J

John Baker

I would like to disable controls on a subform but am having problems
with the following code.


For Each ctlC In Forms!frmOrder!SubformfrmOrderDetails.Controls
If ctlC.ControlType = acTextBox Or ctlC.ControlType =
acComboBox Then
ctlC.Enabled = False
ctlC.Locked = True
End If
Next ctlC

The problem is that the code falls over as it will not disable a control
which has the focus. I have tried different ways to refocus the control to
the main form but can't seem to get it to work.

Any help greatly appreciated.

John Baker
 
A

Allen Browne

Every open form keeps track of which control is active in that form, even
when it is not the active form. When the form becomes active, that's the
control that will have focus.

That means the setting focus to the main form does not change which is the
active control in the subform. Something has to have focus: even if it is an
unbound text box that is 0.01" wide.

(BTW, John, you are a brave man posting your real email address in these
forums, with the number of spambots that are harvesting email addresses
here.)
 
J

John Baker

Thanks for your help Allen.

I'm not sure why my email address comes through to the newsgroup and
therefore not sure how to stop it. I use outlook express to post to the
newsgroup. Any suggestions on how I can stop my email address being posted?

Cheers
John.
 
A

Allen Browne

To mung your email address in Outlook Express:

1. Choose Accounts from the Tools menu.

2. On the News tab, select the server, and choose Properties.

3. On the General tab, under Email address, type an invalid address.

For example, I use:
(e-mail address removed)
since my signature lets a human figure out my email address.
 

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