Referencing parent forms through one common subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created an option box which would allow users to switch between an "edit"
and "view-only" capability. However, once the "view only" button was
selected, I could no longer switch back to the "edit" mode. I got around
this by putting the option box into an unbound subform. I used the coding
below for the option box, and it worked perfectly.

The thing is, I'd like to add this capability to many forms. Is there a way
for me to use the same subform, and have the coding refer to whatever the
active 'parent' form is?

The Me! reference is to the subform, unfortunately. I could create a new
subform for each parent, but I'm hoping there's an easier way. Here is the
coding I used on the subform option box. Any assistance is greatly
appreciated.

Private Sub optVE_Click()
If optVE = 1 Then
Forms!frmProjectInfo.AllowAdditions = False
Forms!frmProjectInfo.AllowDeletions = False
Forms!frmProjectInfo.AllowEdits = False
ElseIf optVE = 2 Then
Forms!frmProjectInfo.AllowAdditions = True
Forms!frmProjectInfo.AllowDeletions = True
Forms!frmProjectInfo.AllowEdits = True
End If
End Sub
 
Actually, I found the answer in another post (I had looked for about 20
minutes before posting in the first place, I swear. I really do appreciate
all you who give up your free time to help newbies like me. I've lived in
this discussion board for the past month or so)

Here's my new coding

Private Sub optVE_Click()
If optVE = 1 Then
Me.Parent.AllowAdditions = False
Me.Parent.AllowDeletions = False
Me.Parent.AllowEdits = False
ElseIf optVE = 2 Then
Me.Parent.AllowAdditions = True
Me.Parent.AllowDeletions = True
Me.Parent.AllowEdits = True
End If
End Sub
 
The thing is, I'd like to add this capability to many forms. Is there a way
for me to use the same subform, and have the coding refer to whatever the
active 'parent' form is?

Yep. The Parent form is

Parent!

in just the same way that the current form is

Me!

John W. Vinson[MVP]
 
Back
Top