Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2012
    Posts
    126

    Unanswered: Refresh on form focus

    I want to refresh a form (requery) on focus. Without adding misc data to the data base could someone tell me if me.requery would work on the onfocus property?

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Actually, in Access, according to Help, a Form can only receive Focus if there are no Controls on the Form that can receive Focus!

    For this kind of thing you need to use the OnActivate property of the Form in question:
    Code:
    Private Sub Form_Activate()
     Me.Requery
    End Sub

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Aug 2012
    Posts
    126
    Quote Originally Posted by Missinglinq View Post
    Actually, in Access, according to Help, a Form can only receive Focus if there are no Controls on the Form that can receive Focus!

    For this kind of thing you need to use the OnActivate property of the Form in question:
    Code:
    Private Sub Form_Activate()
     Me.Requery
    End Sub

    Linq ;0)>
    Yeah wasn't sure. I tried this out and when i open the form you see it requery. But it doesn't seem to be doing it when I need it to. I have a cmdbutton that opens form B. After they are done editing form B and form A is now back in focus I need it to requery so the changes from form b show on form A. The forms aren't linked. Form A runs from a query that includes data from shown in form b. Form B is just a table converted into a form.

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Moving back to FormA from FormB does fire the OnActivate event of FormA, whether you can 'see' it or not. To be honest, I can't imagine how you can 'see' it Requery when the Form opens!

    Where, exactly, do you expect to see this new data, i.e. in a Textbox, in a Combobox or Listbox? If it's the latter two, I believe they'd have to be Requeried independently, also using the OnActivate event.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Aug 2012
    Posts
    126
    Quote Originally Posted by Missinglinq View Post
    Moving back to FormA from FormB does fire the OnActivate event of FormA, whether you can 'see' it or not. To be honest, I can't imagine how you can 'see' it Requery when the Form opens!

    Where, exactly, do you expect to see this new data, i.e. in a Textbox, in a Combobox or Listbox? If it's the latter two, I believe they'd have to be Requeried independently, also using the OnActivate event.

    Linq ;0)>
    When I open the form down on the bottom left hand screen of the window it says "recalculating".

  6. #6
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    That's not coming from the Requery, it's merely the calculations being run when the Form first opens! If the data you're trying to view involves calculations use
    Code:
    Private Sub Form_Activate()
     Me.ReCalc
    End Sub

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    Join Date
    Aug 2012
    Posts
    126
    sweet, i'll give this a try

  8. #8
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Let us know!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  9. #9
    Join Date
    May 2007
    Posts
    38
    what you probably need is for FormA to WAIT for you to finish dealing with FORMB. Then a requery will work. One way is to open FormB is dialog mode

    Because access is event driven, your requery code just runs immediately, without waiting for FormB to close.

    You could also just add a button to FormA, with code me.requery

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •