Results 1 to 7 of 7
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776

    Calculated value in query to insert into a field in talbe?

    Hi all,
    Happy New Year!!!!!!!

    I have a query that popultes a form... OK
    It has the tbl fields on it, and some calculated fields.

    I am trying to use an IIf statement in one field of my query to either let me put value in or automatic insert value in if is not null....


    Not real sure how to word that....

    Field in table/query OpenBalance, standard currency field
    Calculated Field in Query DueAmount, Field is DueAmount: [TotalPay]-[PaidAmount] This only gets value when loan fields are entered. Otherwise, null

    I have tried tons of things and cannot seem to make it work at all.

    So, If the calculated field is null, then I want to be able to fill in the OpenBalance value manually, if its not null, then I want the value of the calculated field inserted into OpenBalance field.

    Obviously this does not work at all, just gives a parameter box.... but was the last thing i tried.
    If(IsNull([DueAmount]),[OpenBalance],[DueAmount])

    Is there a way to put an expresion in the OpenBalance field criteria that will allow me to enter the OpenBalance amount if the DueAmount isNull, and put the value in this OpenBalance field if not isNull....?

    Thanks
    Mr. Stumped

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,903
    Have you looked at the NZ() function ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,891
    Basically, no. Field in query is either editable or it is not. A calculated field (or textbox on form) is never editable. Data entry should be via form, not directly into table or query.

    Saving calculated data is usually unnecessary and often a bad idea. If it can be calculated for saving, it can be calculated when needed.

    Saving calculated value would require an UPDATE action SQL or code (macro or VBA) behind form.
    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.

  4. #4
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Thank you,
    I guess i will have to configure another update then. Its basically a value I need to store in that field in table as so to include in a different update action...
    So, If I do update that calc field, it has to update something else and would save a lot of code to just have it saved in that field....
    This should be interesting to create a new update action... had a ball with the last one.

    Smile\
    Dave

  5. #5
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    OK,
    Going to have to write an update on this. So, any suggestions on where to put this update at? On form properties, on field properties?

    basically i am going to want this to fire once it becomes not null. Before Updat, After Update, OnChange....? Not real sure where to fire this
    at so I get it in a field on the table/form..... Basically want to take this value, put it in the field, so i can click a button and have it going to a different
    form/Table... The biggest problem is i dont have the value till it is created by calculations and would like to input my info and have that value created for me,
    Then put it in the field i really need the value in....

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,891
    Well, why is that second UPDATE action necessary? Again, saving calculated data is usually unnecessary. You have a saved calculation that is based on another saved calculation. If any part of this chain is neglected (original data is modified and any saved calculation is not), the data is worthless.
    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.

  7. #7
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Hi all,
    June7, I was able to work around not saving that calc data and just want to thank everyone for all the assistance this past week!
    Have learned a lot about updates and concat for sure... Did a bunch of concat today and really simplfies the code....

    Thanks
    Dave

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

Similar Threads

  1. Replies: 9
    Last Post: 05-30-2017, 01:19 PM
  2. Replies: 2
    Last Post: 12-30-2014, 01:32 PM
  3. Replies: 1
    Last Post: 03-17-2014, 02:13 AM
  4. Insert new calculated field
    By endri81 in forum Queries
    Replies: 1
    Last Post: 01-19-2013, 03:44 PM
  5. CrossTab - insert a calculated field
    By weiguo.shi in forum Queries
    Replies: 10
    Last Post: 05-23-2011, 01:20 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