identfy a subform

bunji

Registered User.
Local time
Today, 19:37
Joined
Apr 26, 2005
Messages
124
How can i identify a subform in my code.

I am trying to change the properties of a field in a subform from an event on the main form. i have written Forms![frmSubform]![Field1].

When i run the event I get an error that states it cant find the above form. Is there a different way of identifying it being that it is embedded in the main form?
 
You need to specify the main form and then the sub form

Forms![frmmainform]![frmSubform]![Field1]

Hope this helps
 
PMFJI but there is an element missing from the reference. If you are using the Forms collection then the reference to a control on the SubForm will be:
Forms!MainFormName!SubFormControlName.Form.ControlName

If you are executing from the MainForm then you can use the Me. shorthand:
Me!SubFormControlName.Form.ControlName

Here's a good link to BookMark: Refer to Form and Subform properties and controls
 
Ok that works however i have a perculiar thing happening.

I have the event on the subform on open

Code:
Private Sub Form_Open(Cancel As Integer)

Me.Hours.ColumnHidden = True

End Sub

This bit works fine..

On the main form of a cmbo box i have...

Code:
Private Sub AC_SN_AfterUpdate()
         
    [COLOR="red"]If DCount("[Based_Customer]", "tblACDetails", "[AC_Ser_No] = '" & Forms![FrmAirFrame]![AC_SN] & "'") > 0 Then[/COLOR]
    Me.WO_Number = DLookup("[Based_Customer_WO]", "tblACDetails", "[AC_Ser_No] = Forms![FrmAirFrame]![AC_SN]")
    Me.Customer_Scheduled_WO = DLookup("[Cusotmer_Shceduled_WO]", "tblACDetails", "[AC_Ser_No] = Forms![frmAirFrame]![AC_SN]")
[COLOR="Red"]    Forms![FrmAirFrame]![frmAirFrameDetailEntrySubform]![Hours].ColumnHidden = False[/COLOR]
    End If

End Sub

However no matter what record (True or False) is chosen from the cmbo box the Hours field appears. I have checked all the code and cannot find anywhere else that would affect this. The other bits of code only happen the field is True (>0).

any ideas?
 

Users who are viewing this thread

Back
Top Bottom