Oh! That definately makes a difference. In that case it's back to something
similar to the earlier syntax. For simplicity lets say the main form is
named frmMain and you have subform controls sfrmForm1 and sfrmForm2. Both
are directly on the main form (ie neither are sub-sub forms). Lets say the
controls are text1 and text2 and they are on sfrmForm2. The following code
will work from sfrmForm1:
if not isnull(forms!frmMain.sfrmForm2.form.Text1) and _
isnull(forms!frmMain.sfrmForm2.form.Text2) then
MsgBox "Why is there more material on this job?"
End If
From the class module of sfrmForm1 me.parent is a reference to the form
object of the parent form (frmMain). Therefore the above could be written
this way:
if not isnull(me.parent.sfrmForm2.Text1) and _
isnull(me.parent.sfrmForm2.Text2) then
MsgBox "Why is there more material on this job?"
End If
Keep in mind that "sfrmForm1" and "sfrmForm2" are the names of the subform
controls. To find the name of the subform control click once on the subform
control to select it then check the 'Name' property under the 'Other' tab in
the property sheet.
--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.
Dave said:
Is this true even if it refers to a sub-form?
This code is being triggered form a sub-form checking on another
sub-form on my main form!
Sandra Daigle said:
Hi Dave,
In that case you can simply refer to the controls via the "Me"
keyword since 'Me' in this case is a reference to form object.
If not isnull(me..Payment) and _
isnull(me..Balance) Then
MsgBox "Why is there more material on this job?"
End If
--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.
Dave said:
Actually the code is in the exit event of a control on the sub-form
Dave,
Is this code in the class module of the main form? If so here's
what you need:
If not isnull(me.TimeCardPaymentSub.form.Payment) and _
isnull(me.TimeCardPaymentSub.form.Balance) Then
MsgBox "Why is there more material on this job?"
End If
This could be shortened a bit using the With..End With construct:
With me.TimeCardPaymentSub.form
if not isnull(.Payment) and _
isnull(.Balance) Then
MsgBox "Why is there more material on this job?"
End If
End with
--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this
newsgroup. Dave Elliott wrote:
Syntax below is wrong, I know, but this is what I need.
If the sub-form TimeCardPaymentSub control Payment Is NotNull and
on the same sub-form the control Balance IsNull
then messagebox.
If (sub-form) [TimeCardPaymentSub] (Control) [Payment] IsNotNull
and [Balance] IsNull Then
MsgBox "Why is there more material on this job?"
End If