Results 1 to 5 of 5
  1. #1
    rtrinidad is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    4

    Update with Variable

    I'm working on a judging database. Judges enter scores in different 5 categories. These categories could be equal in weight (20% each) but I needed the option to alter the weight in each category.

    This weight % changes based on who uses this database so I created a table with one record to hold the "weighted %" so it can be changed as required. I named the table PERCENTAGE with number fields for each category like TALENT, MEMORY, etc.

    I created an Update Query where all the judges scores were added together and multiplied by a fixed weighted percentage.

    Code:
    (([judge1].[talentscore]+[judge2].[talentscore]+[judge3].[talentscore])*.22)
    What I need is to replace the fixed .22 with the weight % in the PERCENTAGE database. I tried the following but it does not find the value in the PERCENTAGE table.

    Code:
    (([judge1].[talentscore]+[judge2].[talentscore]+[judge3].[talentscore])*[percentage].[talent])
    How do I get the value of the TALENT field in the single record of the PERCENTAGE database?

    Thanks

  2. #2
    rtrinidad is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    4
    OK, I just learned how to setup global variables in a module. Using the current code in my Update Query, how do I retrieve the value of the global variable?

    Update To: (([judge1].[talentscore]+[judge2].[talentscore]+[judge3].[talentscore])*GLOBAL VARIABLE VALUE)

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    You can't directly. You have to create a function that returns the value of the variable, and use that:

    (([judge1].[talentscore]+[judge2].[talentscore]+[judge3].[talentscore])*FunctionName())
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    rtrinidad is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    4
    Got it! Thanks.

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  2. Object variable or With block variable not set
    By walter189 in forum Programming
    Replies: 1
    Last Post: 07-28-2011, 08:51 AM
  3. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  4. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  5. Passing a value from a variable to an update query
    By MUKUDU99 in forum Programming
    Replies: 0
    Last Post: 08-24-2008, 11:14 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