Results 1 to 6 of 6

Thread: ReQuery

  1. #1
    Join Date
    Nov 2009
    Posts
    223

    ReQuery

    I have a Search ComboBox on my Form (source code is qrySearch).

    When i change data on my Form, how do i get that Query/Search ComboBox to update with the latest data withourt closing the form. Eg. I need the data to be refreshed?

    Do you know which Event this code should be inserted coz it doesn;t seem to work unless I click the Search ComboBox twice?

    Code:
    Private Sub cboSearchOnIncomeForm_Click()
    cboSearchOnIncomeForm.Requery
    End Sub
    Thanks.
    What would you attempt to do if you knew you would not fail?

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,542
    In point of fact, the OnClick event of a Combobox doesn't fire until you have 'clicked' on a selection from the dropdown portion of it. Instead, try using the GotFocus event for your Requery.

    Linq ;0)>
    Hope this helps!

    The Devil's in the Details!!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Nov 2009
    Posts
    223
    Missinglinq,

    thanks very much for the clarification regarding OnClick - which makes logical sense now that you have pointed it out.

    The Requery seems to work, but not fully.

    Private Sub Form_GotFocus()
    Me.cboSearchOnIncomeForm.Requery
    End Sub
    This is what i do:-

    1. I click the Search Combobox and check the correct data is there.
    2. I click a different control and change the data.
    3. I stay on the same form and the same record
    4. I click the Search Combobox again but the data is still the same
    5. the data in the Search Combobox only changes if:-

    a) I firstly click a different selection in the Search Combobox (eg. change record) and then on my next selection, the Search Combobox has updated.
    b) I move forward one record and then back again
    c) I close and open the form
    What would you attempt to do if you knew you would not fail?

  4. #4
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,177
    Code:
    Private Sub Form_GotFocus()
    Me.cboSearchOnIncomeForm.Requery
    End Sub
    You misunderstood Linq. What he meant was
    Code:
    Private Sub cboSearchOnIncomeForm_GotFocus()
    Me.cboSearchOnIncomeForm.Requery
    End Sub
    Of course, in order for the combobox to get the focus you need to either 1-click on it, or 2-program the following code from the previous control in the usage:
    Code:
    Me.cboSearchOnIncomeForm.SetFocus
    Sam

  5. #5
    Join Date
    Nov 2009
    Posts
    223
    Sam,

    Thanks very much for your clarification (and coding).

    I still had to click the search box twice to get the result i wanted (it seems to flicker (must be requerying) first).

    I decided the best way was to put the Requery code in the AfterUpdate event of each Control on the Form. This seems to work the best for my purposes.

    Cheers again.
    What would you attempt to do if you knew you would not fail?

  6. #6
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,177
    You're very welcome.

    Sam

Posting Permissions

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