Public Function acessing subform within Mainform

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

Hello all,

I have a app that has a custom menubar, a main form with a subform
embedded. It's the subform that contains the information I am most
concerned with. I've got an "Edit Record" button on my menubar that I
want to use with my subform. By default, the subform has the AllowEdits
= False so my users cannot change information. Since I am using a
menubar and haven't been able to call subroutines, I've placed a
function in a module to do my dirty work. I'm having trouble with it
and maybe it's just a deal with exact refering, but, I haven't been able
to set the allowEdits = True on the subform, just the mainform.

I've tried:

Forms![mainForm]![subform].forms.AllowEdits = True

Me.AllowEdits = True

Screen.ActiveForm.AllowEdits = True

Forms("mainForm").Subform.AllowEdits = True

Can someone point me in the right direction?

Thanks.

Brian
 
Be sure you are referencing the CONTROL on the main form that contains the
subform. This is the only way to get to the subform. By default, the
control may have automatically been given the same name as the subform
itself, which can make this a lot more confusing than it needs to be. For
that reason, I usually change the control name to something else as soon as
it is created.

Once you have referenced the control, you can use it's Form property to gain
access to the subform. (The Form property is the default property of the
control so you can technically do without but I feel that the code is a lot
less confusing to read with it than without.)

Forms("mainForm").mySubformControl.Form.AllowEdits = True

HTH,

George Nicholson

Remove 'Junk' from return address.
 
Brian said:
I have a app that has a custom menubar, a main form with a subform
embedded. It's the subform that contains the information I am most
concerned with. I've got an "Edit Record" button on my menubar that I
want to use with my subform. By default, the subform has the AllowEdits
= False so my users cannot change information. Since I am using a
menubar and haven't been able to call subroutines, I've placed a
function in a module to do my dirty work. I'm having trouble with it
and maybe it's just a deal with exact refering, but, I haven't been able
to set the allowEdits = True on the subform, just the mainform.

I've tried:

Forms![mainForm]![subform].forms.AllowEdits = True

Me.AllowEdits = True

Screen.ActiveForm.AllowEdits = True

Forms("mainForm").Subform.AllowEdits = True


Try using:

Forms![mainForm]![subform].FORM.AllowEdits = True
 
George said:
Be sure you are referencing the CONTROL on the main form that contains the
subform. This is the only way to get to the subform. By default, the
control may have automatically been given the same name as the subform
itself, which can make this a lot more confusing than it needs to be. For
that reason, I usually change the control name to something else as soon as
it is created.

Once you have referenced the control, you can use it's Form property to gain
access to the subform. (The Form property is the default property of the
control so you can technically do without but I feel that the code is a lot
less confusing to read with it than without.)

Forms("mainForm").mySubformControl.Form.AllowEdits = True

HTH,

George Nicholson

Remove 'Junk' from return address.


Hello all,

I have a app that has a custom menubar, a main form with a subform
embedded. It's the subform that contains the information I am most
concerned with. I've got an "Edit Record" button on my menubar that I
want to use with my subform. By default, the subform has the AllowEdits
= False so my users cannot change information. Since I am using a
menubar and haven't been able to call subroutines, I've placed a
function in a module to do my dirty work. I'm having trouble with it
and maybe it's just a deal with exact refering, but, I haven't been able
to set the allowEdits = True on the subform, just the mainform.

I've tried:

Forms![mainForm]![subform].forms.AllowEdits = True

Me.AllowEdits = True

Screen.ActiveForm.AllowEdits = True

Forms("mainForm").Subform.AllowEdits = True

Can someone point me in the right direction?

Thanks.

Brian
Thanks George...I'll try that.
 
Brian said:
George said:
Be sure you are referencing the CONTROL on the main form that contains
the
subform. This is the only way to get to the subform. By default, the
control may have automatically been given the same name as the subform
itself, which can make this a lot more confusing than it needs to be.
For
that reason, I usually change the control name to something else as
soon as
it is created.

Once you have referenced the control, you can use it's Form property
to gain
access to the subform. (The Form property is the default property of the
control so you can technically do without but I feel that the code is
a lot
less confusing to read with it than without.)

Forms("mainForm").mySubformControl.Form.AllowEdits = True

HTH,

George Nicholson

Remove 'Junk' from return address.


Hello all,

I have a app that has a custom menubar, a main form with a subform
embedded. It's the subform that contains the information I am most
concerned with. I've got an "Edit Record" button on my menubar that I
want to use with my subform. By default, the subform has the AllowEdits
= False so my users cannot change information. Since I am using a
menubar and haven't been able to call subroutines, I've placed a
function in a module to do my dirty work. I'm having trouble with it
and maybe it's just a deal with exact refering, but, I haven't been able
to set the allowEdits = True on the subform, just the mainform.

I've tried:

Forms![mainForm]![subform].forms.AllowEdits = True

Me.AllowEdits = True

Screen.ActiveForm.AllowEdits = True

Forms("mainForm").Subform.AllowEdits = True

Can someone point me in the right direction?

Thanks.

Brian
Thanks George...I'll try that.
George,

All that worked beautifully, now how do I do the same for deleting
records from the function.
 
Back
Top