Check field in subform

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • accessbeginerry
    New Member
    • Apr 2010
    • 8

    #1

    Check field in subform

    I have a form with subforms on it (subforms are designed on tabcontrol and each has separate page)

    After user enter information on form and tries to hit "Save" button i would like the access first to check if value in a subform field is not empty.

    It is tblTakeOrder form. When user fills information on form with order id, client name and required date and try to save it - access needs to check SubForm "Order details" if orders price is typed in it

    Trying to use this code but doesn't work:
    Code:
    Forms![TakeOrder]![Orderdetails subform].Form![Price].SetFocus
    If Me!Orderdetails subform.Price Is Null Then
    
    MsgBox "Please insert price of the order"
    Else
    
        DoCmd.RunCommand acCmdSaveRecord
    
        End If
    End Sub
    Last edited by Niheel; Jun 2 '10, 11:11 AM. Reason: additional information, cleaned up the question
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    To refer to a control on a subform with code on the main form, try this syntax:
    Code:
    Me!Subform1.Form!ControlName
    Make sure that you replace Subform1 with the name of the subform control on the main form.

    Comment

    • accessbeginerry
      New Member
      • Apr 2010
      • 8

      #3
      That worked, thank you.

      Comment

      • msvenita
        New Member
        • Jul 2015
        • 1

        #4
        Thanks so much!

        This was very helpful :)

        Comment

        Working...