Subform Load Event

D

Dkline

As I load a subform I want to control the availability of some command
buttons on the form. (BTW - one of the subforms will have a subform).

In lieu of the Navigation Controls, I am to add command buttons that control
the record set. So I have buttons to take you to the First, Last, Previous,
or Next records. The idea is the "Previous" button should not be available
if you are at the start of the recordset and the "Next" button should not be
available when you are at the end of the recordset.

I created a module which handles the availability using the procedure
"ButtonAvailability". All of the controls are named the same on each form
e.g. cmdFirst, cmdLast, cmdPrevious, cmdNext.

In the top level forms this works fine.

Dim strCurrForm As String
strCurrForm = Me.Form.Name
ButtonAvailability (strCurrForm)

The problem is the subforms. I cannot get the syntax right for the
strCurrForm.
strCurrForm = Forms("frmMain")!Form("frmPoliciesInsureds_Sub")
This gives a 2465 error.

Other attempts:
strCurrForm = Forms("frmMain").Form("frmPoliciesInsureds_Sub")

strCurrForm = Forms("frmMain").Form("frmPoliciesInsureds_Sub").Name
strCurrForm = Forms("frmMain").Form(strCurrForm)

What am I missing? Is there a better way to do this?
 
T

Troy

Reference a subform:
Forms("frmMain").NameOfSubFormControl.Form

NOTE: "NameOfSubFormControl" is the name of the subform control on the main
form, NOT the name of the form that subform control contains.

If you want to reference a subform of a subform:
Forms("frmMain").NameOfSubFormControl.Form.Controls("NameOfSubformControlOnSubform1").Form

How to reference a subform control by name:
Forms("frmMain").NameOfSubFormControl.Form.Controls("ControlName")

However, ideally, you just create Recordset clones for each subform and
check the .EOF or .BOF in the FormCurrent event of each Subform.

--
Troy

Troy Munford
Development Operations Manager
FMS, Inc.
www.fmsinc.com


As I load a subform I want to control the availability of some command
buttons on the form. (BTW - one of the subforms will have a subform).

In lieu of the Navigation Controls, I am to add command buttons that control
the record set. So I have buttons to take you to the First, Last, Previous,
or Next records. The idea is the "Previous" button should not be available
if you are at the start of the recordset and the "Next" button should not be
available when you are at the end of the recordset.

I created a module which handles the availability using the procedure
"ButtonAvailability". All of the controls are named the same on each form
e.g. cmdFirst, cmdLast, cmdPrevious, cmdNext.

In the top level forms this works fine.

Dim strCurrForm As String
strCurrForm = Me.Form.Name
ButtonAvailability (strCurrForm)

The problem is the subforms. I cannot get the syntax right for the
strCurrForm.
strCurrForm = Forms("frmMain")!Form("frmPoliciesInsureds_Sub")
This gives a 2465 error.

Other attempts:
strCurrForm = Forms("frmMain").Form("frmPoliciesInsureds_Sub")

strCurrForm = Forms("frmMain").Form("frmPoliciesInsureds_Sub").Name
strCurrForm = Forms("frmMain").Form(strCurrForm)

What am I missing? Is there a better way to do this?
 

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