how to disable fields in a subform

vX987

Registered User.
Local time
Today, 10:20
Joined
Jun 29, 2007
Messages
51
Hi. I have a main form and a sub form.

In my mainfrm I have a text field that is REQUIRED before I can enter any data into the subfrm.

Can anyone help me with this code and how I would relate the two? I know how to do it when all the controls (text fields) are on the same form, but when it's a sub form and a main form then I don't know how to do it anymore.

Help please?

This is what I used for controls that are within the same form.


Private Sub Form_Load()
Me.CellPhone.Visible = False
Me.WorkPhone.Visible = False

End Sub

Private Sub HomePhone_AfterUpdate()
Me.CellPhone.Visible = True
Me.WorkPhone.Visible = True
End Sub


For the codes that I bolded in blue, HOW would I change these to relate to my subform?

I tried this Me!subfrm.Form!ControlName.Enabled and placed this on the On Load of the mainfrm and After Update of the control in the mainfrm, but it didn't work.
 
Last edited:
When you are using this syntax: Me!subfrm.Form!ControlName.Enabled
...the subfrn name is the name of the SubFormControl and not necessarily the name of the form it is displaying, though they may be the same. That is however the correct syntax.
 
Code:
When you are using this syntax: Me!subfrm.Form!ControlName.Enabled
...the subfrn name is the name of the SubFormControl and not necessarily the 
name of the form it is displaying, though they may be the same.
so if 'subfrm' is the name of the SubFormControl (ON THE subfrm or mainfrm?) then what is the ControlName (is this the control in the mainfrm)?

I attached a paint photo of what I'd like to achieve. I am still having no success at this. Maybe with this you can help me?

Feel free to make up names for the controls.

Thanks.

*****edit.......ok, how do I attach a file onto here from My Documents??
 
Last edited:
Forms are displayed on other forms by means of a "SubFormControl". This control has its own name which defaults to the name of the form it is displaying, but need not remain so. You know you are looking at the SubFormControl when the Data tab of the properties sheet shows the LinkChild/MasterFields properties. The name of the SubFormControl is on the Other tab of the property sheet. The form it is displaying is listed in the SourceObject on the Data tab.
 
In re-reading the OP it seems to me that you could get the results you want by disabling the entire SubFormControl until your requirements are met. Then you would use Me.SubFormControlName.Enable = True if your conditions are met or = False if not. You would do the testing in both the OnCurrent event of the MainForm and the AfterUpdate event of whatever control is your trigger.
 
*****edit.......ok, how do I attach a file onto here from My Documents??
Don't use the quick reply box but use the Post Reply button and then scroll down to manage attachments. You can use the quick reply if you then press the Go Advanced button.
 

Users who are viewing this thread

Back
Top Bottom