disabling control on subforms

G

Guest

Good afternoon,

I need a little clarification with regards to subforms and disabling controls.

I have a main form with a subform. If a user checks a checkbox on the main
form I need the subform and its controls to be disabled. However, I receive
an error when the user selects a control on the subform and then navigates to
a new record.

You can’t disable a control while it has the focus

The first line in my sub routine changes the focus to a control on my main
form which is always active. I do not understand why I keep getting this
message?

What is the proper approach to disabling controls?

In another message someone suggested creating a dumbmy control to set focus
on? If this is the proper approach my doesn't my 1st line of code work then?

Thank you,

Daniel
 
K

kingston via AccessMonster.com

If you disable a subform, you should not be able to navigate within it. The
error you're getting is exactly what you think. Try setting the focus to a
control within the main form (e.g. the checkbox itself). Make sure the
checkbox is in the main form and not in the subform. Also, instead of
disabling the form, you can simply make it invisible.
 
G

Guest

If your intent is to allow the user to view the data in the sub form, but
only edit, add, or delette conditionally, here is a routine I use for that
using an option group. I found it easier for the user to understand than a
check box.
The option group Default value is to
The top option button's Caption is Lock and has an option value of 1
the botton option button UnLock and has an option value of 2
Here is how it works:

Private Sub opgLock_AfterUpdate()
If Me.opgLock = 1 Then
Me.Child6.Form.AllowAdditions = False
Me.Child6.Form.AllowDeletions = False
Me.Child6.Form.AllowEdits = False
Else
Me.Child6.Form.AllowAdditions = True
Me.Child6.Form.AllowDeletions = True
Me.Child6.Form.AllowEdits = True
End If
End Sub
 

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