child form or subform

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

Guest

When writing the VBA code, how do you refer to a child form when there are
more than one on a form?

My parent form is called frm_Vendor and the subform I need to reference is
called subfrm_Application. I am trying to create a business rule that says
if Vendor_Nbr on the parent is null and Status_Code = Waiting List, then
Application_Request_Date on the subform is required.

I tried the following in the Parent form's afterUpdate event and also tried
it on the subfrm_Application afterupdate event (I don't really know if it's
where it is supposed to go) and get a 424 Object Required error. (I also
tried using subfrm_Application.Application_Request_Date and it didn't work
either)

If (Me.Vendor_Nbr = "0" And Me.Status_Code = "Waiting List" And
IsNull(Child.Application_Request_Date = True)) Then
MsgBox "An Application Request Date is required when Vendor Number is 0."
Cancel = True
End If

Thanks for your help!
 
Put the code on the before update evnt of the main form, so you can stop the
save if the date field is empty.

Try something like

If (Me.Vendor_Nbr = "0" And Me.Status_Code = "Waiting List" And
IsNull(Me.[subfrm_Application].Form!Child.Application_Request_Date)) Then
MsgBox "An Application Request Date is required when Vendor Number is 0."
Cancel = True
End

The [subfrm_Application] should be the name of the sub form control in the
main form.
 
I found the right code which is listed below but the problem I am having is
the error message pops up and I can't enter the Application Request Date -
anywhere I try to click on the form, it triggers the message below in the
code. Is there some code I am missing? It just keeps going in a loop, I
can't navigate or click anywhere on the form, the message pops up every time.
Thanks for any help you can give!

This is at the Vendor form Before Update event:

If (Me.Vendor_Nbr = "0" And Me.Status_Code = "Waiting List" And
IsNull([subfrm_Application].Form![Application_Request_Date])) Then
MsgBox "An Application Request Date is required when Vendor Number is 0."
Cancel = True
End If

Ofer Cohen said:
Put the code on the before update evnt of the main form, so you can stop the
save if the date field is empty.

Try something like

If (Me.Vendor_Nbr = "0" And Me.Status_Code = "Waiting List" And
IsNull(Me.[subfrm_Application].Form!Child.Application_Request_Date)) Then
MsgBox "An Application Request Date is required when Vendor Number is 0."
Cancel = True
End

The [subfrm_Application] should be the name of the sub form control in the
main form.

--
Good Luck
BS"D


Lori said:
When writing the VBA code, how do you refer to a child form when there are
more than one on a form?

My parent form is called frm_Vendor and the subform I need to reference is
called subfrm_Application. I am trying to create a business rule that says
if Vendor_Nbr on the parent is null and Status_Code = Waiting List, then
Application_Request_Date on the subform is required.

I tried the following in the Parent form's afterUpdate event and also tried
it on the subfrm_Application afterupdate event (I don't really know if it's
where it is supposed to go) and get a 424 Object Required error. (I also
tried using subfrm_Application.Application_Request_Date and it didn't work
either)

If (Me.Vendor_Nbr = "0" And Me.Status_Code = "Waiting List" And
IsNull(Child.Application_Request_Date = True)) Then
MsgBox "An Application Request Date is required when Vendor Number is 0."
Cancel = True
End If

Thanks for your help!
 

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

Back
Top