Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to refer to a subfrom? (Access 2000)

    How to refer to a subform ?


    On my main form called FrmEmployees I have a button to open a report.I want to forbid opening the report in case the liters in the subform are 0.
    To this end I have build an If condition:

    Dim ClLiters As Control
    ClLiters = Forms!FrmEmployees!FrmEmployeesSub.Form!liters
    If IsNull(strLiters) Then
    DoCmd.Beep
    Exit Sub
    Else
    DoCmd.OpenReport strDocName, acPreview, , strWhere

    However, Access point to an error :

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How to refer to a subfrom? (Access 2000)

    You declare CILiters as a Control, that is an object type variable. You must assign a value to an object variable by using Set:

    Set ClLiters = Forms!FrmEmployees!FrmEmployeesSub.Form!liters

    Moreover, you try to assign a value to CILiters, then use strLiters <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to refer to a subfrom? (Access 2000)

    Thank you for your reply. My code doesn

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to refer to a subfrom? (Access 2000)

    Dev Ashish has the best table I've seen for trying to figure out sub and sub-sub form controls and such:
    Refer to Form and Subform properties and controls.

    In addition to a great description, you can download the table as a Word document.

    You'll want to save that for future reference

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

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How to refer to a subfrom? (Access 2000)

    In the first place, there is a difference between Null and 0. Null means empty, blank, missing, no value. But 0 means the number zero; this is a value, it does not count as Null.

    In the second place, testing for a value on a subform being Null (or 0, for that matter) is tricky, for a subform will usually contain multiple records. The test will only look at the current record on the subform, not at every record. What do you want to accomplish?

Posting Permissions

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