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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically update Query/Subform

Status
Not open for further replies.

Eleventy

Technical User
Aug 12, 2010
17
US
So I have a form which defines customer searching (frmCustomerSearch) where the user can input different information into the text boxes and when they hit the search button all the items that match the search criteria pop up based on the query (qryCustomerSearch).

Basically I created a form based on this (frmCustomerSearchSub) and then put it as a subform in my frmCustomerSearch form.

What happens is that I can into my search parameters and if I toggle between design/normal view the information updates but I am looking for a simple update macro or VBA code so that when the user hits "search" the subform automatically updates based on the search parameter.

Suggestions?
 
Do you have any code or Record Source information you could share? Have you tried adding a line of code to requery the subform on the click of the search button?

Duane
Hook'D on Access
MS Access MVP
 
I have one button on the form called btnClearParameters

Private Sub btnClear_Parameters_Click()
Me.txtFarm_Corporation.Value = ""
Me.txtFirst_Name.Value = ""
Me.txtLast_Name.Value = ""
Me.txtAddress.Value = ""
Me.txtCity.Value = ""
Me.txtCounty.Value = ""
Me.txtState.Value = ""
Me.txtPhone_Number.Value = ""
End Sub

and this is then tied to the query qryCustomerSearch where I used the Like statement:

Like [Forms]![frmCustomerSearch].[txtFarm_Corporation] & "*"
- which is then repeated for each line.

I had originally just had placed this VBA code on btnSearch:
DoCmd.OpenQuery "qryCustomerSearch", acViewNormal

which just brought up a table of information that met the search parameters.

I have a subform based on this called frmCustomerSearchSub which I have placed on the frmCustomerSearch and I want that to, when I hit search, update the values in the subform correlating to the search parameters.
 
Its real easy:
I used a button and On Click:
DoCmd.Requery "(name of the form based on your query)"

I used this form as a subform which was "FrmCustomerSearchSub"

works like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top