If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > ReQuery

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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?
Reply With Quote
  #2 (permalink)  
Old
Moderator
 
Join Date: Jun 2005
Location: Richmond, Virginia USA
Posts: 2,407
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
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
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.

Quote:
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?
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
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?
Reply With Quote
  #6 (permalink)  
Old
Registered User
 
Join Date: May 2004
Location: New York State
Posts: 1,177
You're very welcome.

Sam
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On