Reference a control on Sub from Main

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

Guest

I am having trouble understanding the syntac to reference a subform from the
mainform. As is suggested in the form , I am using
http://www.mvps.org/access/forms/frm0031.htm for a reference. I have a cmd
button on the main form to close it. Before I close form I want to be sure
certain controls on subform are not null.
Main form - 'frmRMAExceptionHeader'
SubForm - 'frmRMAExceptionDetail'
The reference suggests Me!Subform1.Form!ControlName
So the code I have is

If
IsNull(Me!frmRMAExceptionDetail.frmRMAExceptionHeader!txtDateofRMAException)
Then
Me!frmRMAExceptionDetail.frmRMAExceptionHeader!txtDateofRMAException.SetFocus
End If

I am getting "object doesnt support this property or method"
 
Hi,
your syntax would be:

If IsNull(Me!frmRMAExceptionDetail.Form!txtDateofRMAException) Then
Me!frmRMAExceptionDetail.Form!txtDateofRMAException.SetFocus
Else
DoCmd.Close acForm, Me.Name
End If

BTW...you might want to test for a Null value AND an empty string...there is
a difference in the two.
HTH
Good luck
 
--
Thanks for any assistance


freakazeud said:
Hi,
your syntax would be:

If IsNull(Me!frmRMAExceptionDetail.Form!txtDateofRMAException) Then
Me!frmRMAExceptionDetail.Form!txtDateofRMAException.SetFocus
Else
DoCmd.Close acForm, Me.Name
End If

BTW...you might want to test for a Null value AND an empty string...there is
a difference in the two.
HTH
Good luck


Thanks Oliver!!
 
Back
Top