Results 1 to 5 of 5
  1. #1
    accessnewb24 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    5

    Trying to get table to give a value based on a calculation

    I'm trying to create a database that has one field that automatically gets filled with a value based on a calculation made from other values input by the user. If the calculation is above a specific value I want the database to say "Fail", otherwise "Pass". My goal is to create a form that a user can easily input numbers into, then have a "pass" or "fail" value displayed on the form as well as saved into the database table itself. I was wondering what the best way to go about this was. I accomplished it by using a query based form but I don't know how to get the query to add new values to the table.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Use an UPDATE action query. Are there multiple records in that table? In VBA would be like:

    CurrentDb.Execute "UPDATE fieldname = '" & something that calculates PASS or FAIL text value & "' WHERE somefield =" & some criteria

    Is this a multi-user split database?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    accessnewb24 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    5
    There are multiple records and when it is finished it will be a multi-user database.So with that piece of code, could I essentially insert a button on the form that will update the table and refresh the data?

  4. #4
    accessnewb24 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    5
    I made a very simple version of what I want to do. The sum of 2 numbers input would give a "Pass" value if it's positive and "Fail" if negative
    Attached Files Attached Files

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Since the field is in the form RecordSource, don't even need UPDATE action, simply:

    Me!Logic = something

    Real trick is figuring out what event to put code into.
    Actually, usually best NOT to save dependent (calculated) data.
    Don't even need to save PASS/FAIL into table - it can be calculated when need.

    So, an expression in query or textbox: IIf([Calculation]<0, "FAIL", IIf([Calculation]>=0, "PASS", "No Data"))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 5
    Last Post: 12-02-2017, 06:54 PM
  2. Replies: 9
    Last Post: 05-30-2014, 11:08 AM
  3. Record selection based on calculation
    By WEJ in forum Programming
    Replies: 5
    Last Post: 05-30-2013, 01:05 PM
  4. Calculation Field in table vs Query calculation
    By Leonidsg in forum Database Design
    Replies: 18
    Last Post: 02-28-2013, 09:38 PM
  5. Replies: 3
    Last Post: 11-29-2011, 12:54 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