Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Requery Command in Access 2007 1

Status
Not open for further replies.
Feb 10, 2009
52
US
I need to use the requery command to requery the data source for a combo box, but I'm wondering if I am missing any other obvious steps. My code is below:

Private Sub ProviderName_AfterUpdate()
DoComd.Requery "ContractorName"
End Sub


For the sake of argument, let's say my combo box is a list of contractors. For each project number, there are several possible contractors for the various types of work like this:

Type of Work ContractorName
Electrical Home Lighting
Plumbing Ace Plumbing
Roofing Harold's Roofing

ContractorName is my combo box. Each different type of work triggers a new line with another ContractorName box to fill in for the project.

Right now, if someone keys in Home Lighting for project 1 and then wants to key it in for project 5, Access won't suggest the name without the user saving and closing the form. I know I need to attach the code to the After Update property. I found the code I mentioned above on another technical assistance website. The ContractorName already has the query of all the existing Contractor Names behind-the-scenes as the RowSource. What else should I be doing to get this to function correctly?
 
Here is your code:

Private Sub ProviderName_AfterUpdate()
DoComd.Requery "ContractorName"
End Sub

But at this event, the whole record is not saved yet.

So try this.

Private Sub Form_Current()
DoComd.Requery "ContractorName"
End Sub

or

Private Sub ContractorName_Enter()
DoComd.Requery "ContractorName"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top