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

How to refresh subform

Status
Not open for further replies.

puppygirl3939

Technical User
Sep 15, 2003
21
0
0
US
Please help!

I have two subforms in one main form. Subform 1 called county and subform 2 called region. The region form is populated by what county the user selects in the county subform. The code below is working fine by adding the region to the region table but I have to exit the form and then enter again in order to see the region on the subform. The code that I am using is

Private Sub Counties_Click()
Dim strCounty As String
Dim strRegion As String
Dim dbsFUD As Database
Dim recPartners As DAO.Recordset
Dim frmRegion As DAO.Recordset

Set dbsFUD = CurrentDb
Set recPartners = dbsFUD.OpenRecordset("Ref_Main_Regionals")
Set frmRegion = dbsFUD.OpenRecordset("RefMainRegionalsQuery")

strRegion = recPartners("RegionalPartners")

If strCounty = "Orange" Then
strRegion = "Progress Energy"
End If

'Update Tables and Forms
recPartners.AddNew
recPartners("Referral ID Number") = Forms![frmRefMain]!txtRefID
recPartners("RegionalPartners") = strRegion
recPartners.Update
frmRegion.Requery
End Sub
 
Put

Subformname.Form.Requery

in the code. Replace Subformname with the name of the subform control, and put Me.Requery above it to refresh the main form as well.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top