Results 1 to 6 of 6
  1. #1
    TOMMY.MYERS668's Avatar
    TOMMY.MYERS668 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Location
    West Virginia
    Posts
    77

    Calculated fields not putting their answer on the main table?


    This is probably something incredibly simple and im just being dumb but, I have several fields on a form - one calculates a date minus 1 day. one calculates a ratio and 1 pulls one of the numbers for the ratio from another table. All of the calculations work properly and show the correct numbers on the form for each record. However they are not updating the master table with their values...?? Any ideas?

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Most people here are going to ask "What's the problem?"

    It is very, very, seldom appropriate to store calculated values in a Table. You simply re-run the calculation, as needed, whether in another Form, Report or whatever.

    Having said that, a Control's content is only saved to an underlying Table if the appropriate Field from that Table is given in the Control's Control Source Property, and at a guess, that's where you've got the actual expression for your calculation.

    If you had a valid reason to store the calculated value, you'd need to move the expression elsewhere and set the Control Source to the Field in the Table.

    A common method of doing this, if the expression depends on the value entered in another Control, is to do the calculation in that Control's AfterUpdate event, and set the Control Source as outlined above.

    Linq ;0)>

  3. #3
    TOMMY.MYERS668's Avatar
    TOMMY.MYERS668 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Location
    West Virginia
    Posts
    77
    well as an explanation it's the army.. and they are insane... its a database that stores all of the classes that are being taught by a division. the three calculation are simply to make it less for them to screw up. they put in the start date aand end date of the class . . It auto cals the report date. It chooses the instructor student ratio based on wich mos class is chosen from a drop down because if they enter that wrong it wont tell them the proper number of instructors they need and then we end up short. but the main problem is Division who wants to see every little thing possible... welcome to micromanagement at its worst level.

  4. #4
    TOMMY.MYERS668's Avatar
    TOMMY.MYERS668 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Location
    West Virginia
    Posts
    77
    OK , i read that again and i swear 2 new things showed up in it. You are correct my calc is in the control source so that is bad and it needs to be set to the field name on the main table then I need to put and after update in on the start date to do the date calc and assign it to the reportdate var. Ill give that a shot thanks for the help I'll let you know how it turns out.

  5. #5
    TOMMY.MYERS668's Avatar
    TOMMY.MYERS668 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Location
    West Virginia
    Posts
    77
    Ok so I put this into the vba on after update for the select start date field :
    Private Sub START_DATE_AfterUpdate()
    Dim reportdatecalc As Date
    reportdatecalc = DateAdd("d", -1, Me![START DATE])
    Me![REPORT DATE] = reportdatecalc
    End Sub

    This works like a charm and your are a genuis however I allready have one of these thats calcs the Ratio and its not working so I'm gonna pic that code apart for a few and see if I can figure it out. In case you wanna have a look it is:

    Private Sub COURSE_AfterUpdate()
    'AfterUpdate event code
    'Check to see if course was selected
    If Not IsNull(Me![COURSE]) Then
    'set up variable for ratio
    Dim lngRat As Long
    'place ratio value into variable
    lngRat = DLookup("[Ratio]", "[ISR Table]", "[MOS]='" & Me![COURSE] & "'")
    'set value of isr on form
    Me![ISR] = lngRat
    Else
    Exit Sub
    End If
    End Sub

  6. #6
    TOMMY.MYERS668's Avatar
    TOMMY.MYERS668 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Location
    West Virginia
    Posts
    77
    ok figured that one out too! I hadnt change the control source back on that one yet... you're awesome boss.

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

Similar Threads

  1. Replies: 1
    Last Post: 03-27-2012, 05:25 PM
  2. Replies: 4
    Last Post: 03-05-2012, 10:20 AM
  3. calculated fields appearing in table
    By jamhome in forum Access
    Replies: 16
    Last Post: 07-19-2011, 02:57 PM
  4. Replies: 3
    Last Post: 07-13-2011, 08:01 AM
  5. Replies: 1
    Last Post: 04-25-2011, 12:36 PM

Tags for this Thread

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