Results 1 to 5 of 5
  1. #1
    deepakg27 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    160

    Requery command in Forms

    Hi Guys,

    I am working on Billing database. I have two form frmBill & frmBillDetails, both have queries which need to run on the fly based on (new or updated) data entered by the user.

    I am using Dlookup command to pass the arguments to the query and get the desired results.

    Till here everything is fine. Now as i load the form query runs and returns the answer based on the current arguments, but when I enter new data or update nothing happens. To counter this I used requerry command in AfterUpdate event of the field TAX in frmBillDetails. But the problem is as soon the requerry runs the tab goes to the very first record of the current form. For Example in frmBillDetails, if I have 15 Sub details for the current sub form and I am making a change in 14 record, requery will move the focus to the very first record. Similar problem is being faced in frmBill, in that if I am working on bill number 35, after requery it will move to bill number 1.

    I want to run the requery but keep the focus right where it was. Kindly help on how to achieve this. Thanks.



    Regards
    Deepak Gupta

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    To Requery a Record Source and then return to the Current Record, where [UniqueID] is a Field unique to only one Record, you can use something like this:

    Where [UniqueID] is Text

    Code:
     Private Sub SaveRequeryReturn_Click()
    
    Dim UF_Rec As String
       
       UF_Rec = Me!UniqueID
       Me.Requery
       Me.Recordset.FindFirst "[UniqueID] = '" & UF_Rec & "'"
    
    End Sub

    Where [UniqueID] is Numeric

    Code:
     Private Sub SaveRequeryReturn_Click()
    
    Dim UF_Rec As Integer
       
       UF_Rec = Me!UniqueID
       Me.Requery
       Me.Recordset.FindFirst "[UniqueID] = " & UF_Rec
    
    End Sub


    Not sure, from your description, exactly what you're doing, but if the 'desired results' involves calculations, as simply Me.ReCalc may be what you need. ReCalc does just that, reruns all calculations...without moving focus to the first Record.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    deepakg27 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    160
    Dear MissingLinq,

    Thanks for your suggestion. I have yet not tried the code provided by you. Will try and post if any problems arise.

    BUT for now I would like to thank you for suggesting Me.ReCalc. It solves my problem and i am able to get the desired results. A big Thanks.

    Regards
    Deepak Gupta

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I thought that ReCalc might be the definitive answer, but just could't be sure from your description.

    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    deepakg27 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    160
    Thanks for the help.

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

Similar Threads

  1. Command Buttons and Forms
    By clrockwell15 in forum Reports
    Replies: 5
    Last Post: 07-03-2017, 06:59 PM
  2. Replies: 3
    Last Post: 10-15-2015, 08:48 PM
  3. Requery with Command button
    By Bongobob21 in forum Forms
    Replies: 12
    Last Post: 03-13-2015, 09:25 AM
  4. Replies: 5
    Last Post: 01-16-2013, 03:48 PM
  5. Simple Requery Structure - Continous Forms
    By JeffG3209 in forum Programming
    Replies: 8
    Last Post: 06-10-2011, 07:18 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