Results 1 to 3 of 3
  1. #1
    talpel is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2015
    Posts
    4

    auto calculate fields

    Hello,


    I'm creating a basketball league data base, and I have a table with all the match-ups in the league.
    In the field [home team score] and [away team score] there will be the score, and I want to add a field for
    "points gained for home\away team" which will calculate which one is bigger (home or away score) and fill with the numbers 1/2 (as in a real basketball league)

    I tried to create a new field with "Calculated" data type, but wasn't able to write what I wanted.

    it should be smth like
    =1 if [home team score]<[away team score] else =2

    Can you help me build this expression for the Expression Builder??

    Thanks!

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You should do this in a Query, not in a Table. The newer versions of Access do allow for calculated fields in Tables, but it is not recommended to put your calculations there. Other relational database programs do not allow for calculated fields in tables.

    You want to use an Immediate If statement (see: https://support.office.com/en-us/art...rs=en-US&ad=US)
    Your expression would look something like:
    Code:
    PointsGained: IIF([home team score] < [away team score],1,2)

  3. #3
    talpel is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2015
    Posts
    4
    Thank you very much!

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

Similar Threads

  1. Replies: 3
    Last Post: 05-03-2014, 11:00 AM
  2. Calculate distance using fields in form
    By wnicole in forum Access
    Replies: 1
    Last Post: 09-28-2013, 09:05 AM
  3. How to calculate fields in 2 tables in VBA
    By dluhut in forum Access
    Replies: 2
    Last Post: 04-23-2013, 05:08 PM
  4. Replies: 5
    Last Post: 02-11-2013, 08:34 AM
  5. Replies: 1
    Last Post: 08-17-2011, 11:13 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