How to append calculated value from query into table field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JenniferM
    New Member
    • Oct 2010
    • 33

    How to append calculated value from query into table field

    Annnnnd I'm back again, with a new problem, of course.

    I've got a table, TblKneeExamInfo, which corresponds to a form, FrmKneeExamInfo. In it, there is a section where I need to input patient answers for questions regarding pain, swelling, etc (These are all numeric values ranging from 0-4).
    Currently I have a query set up that calculates the overall subscore for a particular group of questions, say for those regarding pain. This is the SQL I'm using to calculate my pain subscore (QryKOOSPainCalc):

    Code:
    SELECT TblKneeExamInfo.FUKneeID, TblKneeExamInfo.FUKneeKOOSFilledOut, TblKneeExamInfo.KUKneeKOOSp1, TblKneeExamInfo.KUKneeKOOSp2,
     TblKneeExamInfo.KUKneeKOOSp3, TblKneeExamInfo.KUKneeKOOSp4,
     TblKneeExamInfo.KUKneeKOOSp5,
    TblKneeExamInfo.KUKneeKOOSp6, TblKneeExamInfo.KUKneeKOOSp7,
     TblKneeExamInfo.KUKneeKOOSp8, TblKneeExamInfo.KUKneeKOOSp9,
     (([TblKneeExamInfo]![KUKneeKOOSp1]+
    [TblKneeExamInfo]![KUKneeKOOSp2]+
    [TblKneeExamInfo]![KUKneeKOOSp3]+
    [TblKneeExamInfo]![KUKneeKOOSp4]+
    [TblKneeExamInfo]![KUKneeKOOSp5]+
    [TblKneeExamInfo]![KUKneeKOOSp6]+
    [TblKneeExamInfo]![KUKneeKOOSp7]+
    [TblKneeExamInfo]![KUKneeKOOSp8]+
    [TblKneeExamInfo]![KUKneeKOOSp9])*100)/36 AS
    FUKneeKOOSPain
    FROM TblKneeExamInfo
    WHERE (((TblKneeExamInfo.FUKneeID)=
    [Forms]![FrmKneeExamInfo]![FUKneeID]));
    It's putting the value in a column of the query called FUKneeKOOSPain. I have it calculating the subscore for only the current recordset that is open. I know this calculation is working correctly because I currently have an unbound listbox on the form which is pulling the value for that query, and it is correct.

    Here's my question: My idea was to employ the use of an append query to add the value from QryKOOSPainCalc to TblKneeExamInfo .FUKneeKOOSPain. I've never used an append query before.... I know you can take an entered value from a table and insert it into another table. HOWEVER, I know there is more flexibility in them than that-- I should definitely be able to add a value from a query as well. How would I go about setting one up that adds a calculated query field to a table field? Or is there a better way to go about this that I have overlooked?
  • gnawoncents
    New Member
    • May 2010
    • 214

    #2
    Perhaps I'm misunderstandin g your intent, but it sounds like you want to do an update, not append, operation. In other words, you want to modify an existing record rather than add a new one. Create an update query that looks like this:

    Code:
    Field: FUKneeKOOSPain
    Table: TblKneeExamInfo
    Update To: ([KUKneeKOOSp1]+[KUKneeKOOSp2]+...+[KUKneeKOOSp9])*100/36
    Criteria:
    You will need to replace the "..." with the rest of your fields to add, and only need to include criteria if you do not want to update certain records, like ones without any knee pain data (e.g. IsNull([KUKneeKOOSp1])).

    Please let me know if I am not understanding what you need. Thanks.

    Comment

    • JenniferM
      New Member
      • Oct 2010
      • 33

      #3
      Yeah, that makes complete sense in hindsight (now I feel dumb). I've changed it to an update query and it's working fantastically. I guess "appending" is when you are creating tables/fields to put data in that do not exist already-- i.e. literally adding new information then, correct?

      Comment

      • gnawoncents
        New Member
        • May 2010
        • 214

        #4
        Pretty much. Appending is adding a new record to an existing table. I'm glad it's working for you now. :)

        Comment

        Working...