Results 1 to 5 of 5
  1. #1
    Join Date
    May 2002
    Posts
    395

    Unanswered: error in referencing a subform

    Im trying to check a field in the subform for Null values and if so prompt user to enter value in the fields. But this is the error message I received:

    You entered an expression that has an invalid reference to the property Form/Report.

    Is there something wrong with the syntax?

    This is the code in the Main form:

    Private Sub Form_Close()
    If (Not IsNull(Forms![Production Sheet Input]![Production Sheet Sub 1]![Part Number]) And IsNull(Forms![Production Sheet Input]![Production Sheet Sub 1]![Cycles])) Then

    MsgBox "Please enter the Number of Cycles", vbOKOnly

    (Forms![Production Sheet Input]![Production Sheet Sub 1]![Cycles])).SetFocus
    End If

    End Sub

    Please help I've been working on it for two days!

    Thanks!!

  2. #2
    Join Date
    Dec 2002
    Posts
    60

    Re: error in referencing a subform

    Forms![Production Sheet Input]![Production Sheet Sub 1]![Part Number]:

    I assume [Production Sheet Sub 1] is the subform object and [Part Number] is the field on the subform. If so try:

    Forms![Production Sheet Input]![Production Sheet Sub 1].FORM![Part Number]

  3. #3
    Join Date
    Jan 2003
    Posts
    56
    Good site for how to reference controls on subforms and other forms:



    http://www.mvps.org/access/forms/frm0031.htm


    Really helped me out.

    C.

  4. #4
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820

    Re: error in referencing a subform

    Originally posted by bc301
    Forms![Production Sheet Input]![Production Sheet Sub 1]![Part Number]:

    I assume [Production Sheet Sub 1] is the subform object and [Part Number] is the field on the subform. If so try:

    Forms![Production Sheet Input]![Production Sheet Sub 1].FORM![Part Number]
    or you could try just

    forms![Production Sheet Sub 1]![Part Number]

    i think that should work if the sub form is called Production Sheet Sub 1
    i normaly use the syntax

    Form_Formname.Part Number
    ie
    Form_ByStatus.status to get the value in the txtbox status on the form ByStatus

    which works fine if you don't use spaces in the form names
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  5. #5
    Join Date
    May 2002
    Posts
    395

    subform referencing

    Thanks all of your replies and good suggestions.
    I finally got it working. I place the code in the main form and reference the name of the subform and controls it works.

    sub routine_in_Main_form

    If (Not IsNull([Production Sheet Sub 1].Form![Part Number])) And IsNull([Production Sheet Sub 1].Form![Cycles]) Then

    ..

    end if

    Thanks !!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •