Results 1 to 4 of 4
  1. #1
    jdm0804 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    3

    Form calculations not affecting table

    (Access 2003)
    On a form I have a field that calculates age from a date of birth. It works great, but it's only visible on the form. How do I make the field store the data in a table?

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Have you considered NOT putting the calculated age into the Table?

    You can write a Query that does the calculation for you - in a similar manner to what is happening on your Form.

    This SQL would give you the AgeOfPerson in years.
    Code:
     
    SELECT Field1, Field2, DateBorn, DateDiff("y",[DateBorn],Date()) AS AgeOf Person
    FROM TableName;
    The calculated Age is going to change every day - so I would think it would be worth considering not putting the calculated age into the table?

    Perhaps you could explain why the Age needs to be inserted into the table?

  3. #3
    jdm0804 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    3
    I need it to be on the report. If it doesn't need to be on the table for that to happen, then that is just fine too. I'm still a n00blet, so I don't know this stuff! How do I go about writing said query?

    Also, what does SQL mean?

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    SQL is Structured Query Language.

    It is the text representation of what you see when you create a Query in Access.

    If you have a query in Access - open it & go to View -> SQL View.
    You will see the SQL of your Query.

    To create a query like the one I outlined:
    1. Create a Query.
    2. Choose the Table in which your data is.
    3. Dbl-Click each field that you want on your Report so that it goes into the lower pane of your query.
    4. In the next empty field to the right of the last field that you put in the lower pane Type something this:

    Code:
     
    Age: DateDiff("y",[DateBorn],Date())
    . . . and Tab off the field.

    5. Save your query & Run it.

    You should now see all the fields you selected for your query - plus the Age field with the age of the person in years.

    If everything looks right in your data . . .

    Close the result pane and in Query Design View - click View -> SQL View in the top left corner of the Access window. You should see your SQL.

    Next:
    Create a new report using the Report Wizard.
    When you are asked where the data for your report will come from - choose the Query that you just created.

    I hope this helps.

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

Similar Threads

  1. Form/Subform Calculations
    By sidewayzalex in forum Forms
    Replies: 0
    Last Post: 08-15-2011, 01:11 PM
  2. Resizing Forms (Properties affecting behavior)
    By ajetrumpet in forum Tutorials
    Replies: 0
    Last Post: 07-17-2011, 04:05 PM
  3. Calculations in a form
    By elmere in forum Forms
    Replies: 3
    Last Post: 04-27-2011, 04:11 PM
  4. Replies: 22
    Last Post: 03-15-2011, 07:17 AM
  5. Calculations in Form not saving to table
    By ld8732 in forum Forms
    Replies: 1
    Last Post: 01-24-2011, 07:31 PM

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