Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't access table fields (Access 2003)

    Still struggling, I'm afraid. In this lottery database I'm trying to produce I have a table for MemberDetails and a table for DrawDetails. These are linked by a one to many relationship.
    The database also needs to hold DrawYear and DrawNumber - these are the values that a member's individual draw details are tested against to see if their lottery number gets entered into an actual draw.
    DrawYear and DrawNumber are not member related - they 'belong' to the lottery - so they dont' belong in the MemberDetail table or the DrawDetail table. Not knowing any other method of holding 'constants' I've put them in a table CurrentDraw ; this table does not have a relationship to either MemberDetails or DrawDetails.
    I have queries which can access this table OK and produce calculated fields - but I can't get get these two values displayed on a form. The main form is based on the MemberDetails table and the subform is based on the DrawDetails table.
    I've tried adding a text box with its control source set to =[CurrentDraw].[DrawYear] but it displays a #NAME? error.
    How should I reference these fields from the form and/or from a VB routine, please.
    And why am I able to go into Expression Builder for the ControlSource property of the text box on the form and build a reference to the [CurrentDraw].[DrawYear] which then fails when I open the form?
    Thanks
    Silverback
    Silverback

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

    Re: Can't access table fields (Access 2003)

    The expression builder doesn't know what can and what cannot be used on your form.
    Assuming that your CurrentDraw table contains a single record, you can use
    <code>
    =DLookup("DrawYear","CurrentDraw")
    </code>
    in the control source of a text box to retrieve the value of the DrawYear field in the CurrentDraw table.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can't access table fields (Access 2003)

    Thank you, again
    Silverback
    Silverback

Posting Permissions

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