Results 1 to 5 of 5
  1. #1
    cnstarz is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Oct 2010
    Posts
    31

    Getting #Name? error on form

    Hello! I'm a newbie trying to build a new database from scratch, and am learning as I go.

    I have a linked table called Main (this table already exists in a previous, hard-to-use database); the form for Main is called "MainForm".

    I have a query called "Expiration" which which calculates the Expiration dates of TS Clearances for each record using the DateAdd function.



    On MainForm, I have a field called "Expiration Date". This field is supposed to return the calculated expiration date from the "Expiration" query. Of course, this date is different from record to record because not everyone's clearance expires on the same date.

    The problem is that the "Expiration Date" field is returning a value of "#Name?". The control source of that field is "= [Expiration]![ExpirationDate]". I arrived at this control source by clicking the "..." button next to "Control Source" in the Property Sheet while in design view of MainForm, and simply navigating to Queries>Expiration>ExpirationDate>"<Value>". I then hit "OK" and it populated the Control Source field for me.

    Any ideas as to why the field displays "#Name?" when i switch over to Form Mode to view the form? Thanks!

  2. #2
    kimmer is offline Competent Performer
    Windows 7 Access 2010 (version 14.0)
    Join Date
    May 2010
    Posts
    100
    It just doesn't work like that. A Control Source property cannot reference an unopen object that isnt its own record source.

    You can base the form on a query that includes your calculated field or
    you can do the calculation directly in the Control Source property (provided the original date field is in the record source for the form).

    If your original date isnt part of the record source for the form, you can insert a subform based on your query.

  3. #3
    cnstarz is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Oct 2010
    Posts
    31
    So I can just create a query, and then create a new form based off the query. If the end-user were to edit any of the fields of this new form, would the changes also be reflected in the table that the query is based off? If so, then this solution will be what I need.

  4. #4
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    Yes as long as all the required fields are included in the query, the user as the permissions to write to the table, etc...

  5. #5
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    Unless you are recording the expiration date in a table, I would suggest using Kimmer's second suggestion and just do the calculation on the form itself.

    In the Expiration Date field of your form, set the Control Source to something like:
    =DateAdd("d", 14, recordDate)

    If the recordDate (or whatever you call it) isn't on the main form you would have to add it but you could hide it from sight by setting the Visible property to False if you don't want both dates displayed.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Where Condition - form error
    By catat in forum Forms
    Replies: 5
    Last Post: 07-15-2010, 07:40 AM
  2. Error in form code
    By devesa in forum Access
    Replies: 3
    Last Post: 05-25-2010, 10:15 AM
  3. #Name? error in Form text box.
    By aligahk06 in forum Forms
    Replies: 6
    Last Post: 04-24-2010, 11:21 PM
  4. Error In Opening Form
    By cwwaicw311 in forum Forms
    Replies: 1
    Last Post: 03-10-2010, 09:18 AM
  5. Error when clearing form
    By turbo910 in forum Forms
    Replies: 11
    Last Post: 11-26-2009, 11:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums