Results 1 to 7 of 7
  1. #1
    ItsRoland is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    111

    Question Regarding Functions in Queries

    I've got a form based off a query. For simplicity's sake, lets call the form "Form1" and the query "Query1". One of the fields in Query1 is calculated by a function. This is working perfectly.



    However..

    If I don't scroll through certain records on Form1, it doesn't update the record on the table, i.e. if I open Form1 all the visible records will update, but all the records you need to scroll down to see do not update.

    My question is: Is this supposed to happen, or is something not behaving correctly? Personally I think this is working properly, but I talked to someone with more access experience than myself and they seem to think otherwise. I tried searching around but couldn't find anything, could just be I wasn't phrasing my search correctly. Regardless, I just want to confirm if whats happening is normal functionality or not.

    Thanks!

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    If it is simply a "Select" query and not an "Action" query (like an "Add" or "Update" query), then it doesn't matter, since nothing is really being permanently updated anyway.
    A calculated field in a "Select" query is real-time, and simply does the calculation when called. If other records are not being called, then the calculation is not being done to them at that point in time. But since nothing is permanently being altered, it shouldn't matter.

  3. #3
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,142
    By default access doesn't "process" all the underlying records displayed on a form, it only pulls the first x number of records based around what the form can display.

    Your description of it "not updating the table" is a little confusing, a function in a query wouldn't update a value unless you were running an update query.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    ItsRoland is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    111
    My apologies for the confusion.

    Query1 is a Select Query, I forgot that the function itself is what updates the tables, not the query.

    Therefore I imagine I would need to remove the update table functionality from the function and change the query to an update query to achieve the desired results, correct? (i.e. when Form1 is opened, it will update all the records)

    Would changing Query1 from a select query to an Update query cause any issues with Form1 (The form that uses it as a RecordSource)?

  5. #5
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,142
    You can't use an update query as a record source for a form, it doesn't return any records.

    Your sequence of events needs to be on form open, run the update query.
    The record source for the form then simply will query the table with the updated records.
    Last edited by Minty; 08-06-2018 at 10:08 AM. Reason: Typo's
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,696
    If you want the function to update a value in the table, as the records are displayed in the form, the function should not be in the query but should be the datasource for the control (textbox) on the form.
    OR
    the form_current event could call the function:
    sub Form_Current()
    textbox1 = MyFunction
    end sub

  7. #7
    ItsRoland is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    111
    Sorry for the delay in response


    I was able to get what I wanted by simply creating an update query with the same information as the select query, and using that anytime I need to update the table with information.

    Thanks for the help!

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

Similar Threads

  1. Replies: 4
    Last Post: 09-17-2017, 01:34 PM
  2. Logical Functions in queries
    By Mschneider331 in forum Access
    Replies: 3
    Last Post: 10-31-2016, 06:14 PM
  3. Logical Functions in Queries
    By Mschneider331 in forum Access
    Replies: 5
    Last Post: 10-31-2016, 09:59 AM
  4. functions / queries
    By merlin2049er in forum Queries
    Replies: 7
    Last Post: 06-10-2015, 09:29 AM
  5. User functions within queries...
    By ChaosInACT in forum Queries
    Replies: 5
    Last Post: 01-19-2012, 06:39 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