Results 1 to 6 of 6
  1. #1
    jbeets is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2020
    Posts
    94

    When I requery the form jumps to the first record in the table

    The user inputs data in the form which is bound to the CompletedAudits table.

    There are comboboxes on the form which the user selects in order to create a score. The questions are weighted and so I have a query that provides the “points earned” based on the responses to each cbo. Then I use a DLookup to the query to obtain the total score when the “Calculate Score” button is pressed.



    All of this is working so far except when the user needs to change the response in the cbo or to recalculate the score. If I use me.requery in the after update event, the record jumps to the first record in the table. I need to refresh the query when the selection in the cbo changes or the score is recalculated but I am not sure how to do it.

    I have never made a form that is calculated based on a query so I am not sure what I am doing wrong here. Below is the vba I am currently using.

    Code:
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Total Score for Call Opening
    
    Private Sub btnCallOpeningScore_Click()
    txtCallOpeningScore.Value = DLookup("[Call Opening Score]", "qry_CallOpeningScore", "[ID] =" & Me.txtMasterID.Value)
        'Me.Requery
    End Sub
    I'm sure I am missing something obvious - I really appreciate any help you can provide. Thanks!
    Last edited by jbeets; 01-17-2021 at 10:38 AM. Reason: fixed code error

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Investigate the use of a bookmark.
    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
    jbeets is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2020
    Posts
    94
    I found that using Me.Refresh instead of Me.Requery worked to update the data in the form allowing me to calculate the score and does not cause the record to jump as requery did.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    I would also recommend you research how to use a bookmark with a requery to return to the original record.
    However, also try using Me.Recalc
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    In regard to using bookmarks to navigate a form check out David W Fenton's code here:
    https://stackoverflow.com/questions/...obox-in-access

    Different question but you'll get the idea.

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

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

Similar Threads

  1. Replies: 3
    Last Post: 10-07-2020, 06:14 AM
  2. screen jumps to top of form when typing in text box
    By jbeets in forum Database Design
    Replies: 2
    Last Post: 07-23-2020, 10:06 AM
  3. Autonumber field jumps on creating new record
    By Keith Maxwell in forum Programming
    Replies: 1
    Last Post: 08-05-2014, 07:42 AM
  4. Replies: 4
    Last Post: 08-05-2013, 06:41 PM
  5. Requery only one record on a form
    By mkallover in forum Forms
    Replies: 3
    Last Post: 01-26-2011, 09:31 AM

Tags for this Thread

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