what mistake is in my Form current code


G

Guest

The below code I am using on a form current event. All is working fine, all
the controls get disabled except the subform first field is getting locked
but not changing its color like other after disable (i mean grey background).
Which makes the look not good. Could you please correct my code, so that all
the controls can be disabled with its same disabled looks. Pls. Note my
subform name is "RecTab2B" :


Private Sub Form_Current()
On Error Resume Next
Dim ctl As Access.Control
If Me.PostedChk = True Then
For Each ctl In Me.Detail.Controls
ctl.Enabled = False
Next ctl
For Each ctl In Me.RecTab2B.Controls
ctl.Enabled = False
Next ctl
Else
For Each ctl In Me.Detail.Controls
ctl.Enabled = True
Next ctl
For Each ctl In Me.RecTab2B.Controls
ctl.Enabled = True
Next ctl
End If

End Sub


Thanking you all in advance.

Regards.

Irshad
 
Ad

Advertisements

A

Allen Browne

If you want your code to execute for each subform on your form, and
potentially for subforms in the subforms and so on, you need call the code
recursively.

There is an example of doing that in this article:
Locking bound controls
at:
http://allenbrowne.com/ser-56.html

Since you want to set the Enabled property rather than the Locked property,
change the line:
ctl.Locked = bLock
to:
ctl.Enabled = bLock
 

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