Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Aug 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Syntax for subForm (Access 2000)

    Hi...
    I'm having trouble dealing with subform. I have a form called "frmCurrentResults" in which I enter current sales and purchasing information. It contains a field named "curSales." There is also a subform named "sfrmLastYearResults" with a field called "curLastYearSales". I'd like to add a control in which I subtract last year's results from this years to see our results.

    I've tried ([curSales] - [Forms]![sfrmLastYearResults].[curLastYearSales]) but it gives me an error.

    I've also tried ([curSales]-[Me]![sfrmLastYearResults].[curLastYearSales]) and that also errors.

    Any suggestions what I'm doing wrong.

    Thanks in advance.

    Larry

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

    Re: Syntax for subForm (Access 2000)

    The first expression won't work because a subform is not part of the Forms collection.
    The second one won't work because Me is VBA. You can't use it in the control source of a control.
    Try this:

    =[curSales]-[sfrmLastYearResults]![curLastYearSales]
    or
    =[curSales]-[sfrmLastYearResults].[Form]![curLastYearSales]

    Notes:
    - The control source must begin with =
    - You must use the name of the subform as a control on the main form; this is not necessarily the name it has in the database window. To check, open the main form in design view, and click once on the subform. The Controls dropdown in the Formatting toolbar, and the Name property in the Other tab of the Properties window will display the control name.

  3. #3
    New Lounger
    Join Date
    Aug 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Syntax for subForm (Access 2000)

    That's it, Hans...Thank you so Very Much!!!

Posting Permissions

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