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

Append and Refresh Subforms 1

Status
Not open for further replies.

steve1961

Technical User
Jun 10, 2003
12
IE
Hi,

I have a main form with a combo box (cboTempSelect)and command button(cmdSelectTemplate) .
When the user selects a text in the combo box (cboTempSelect), the user then clicks the command button (cmdSelectTemplate)which fills in data in 4 subforms of this main form.

Private Sub cmdSelectTemplate_Click()
On Error GoTo Err_cmdSelectTemplate_Click

DoCmd.SetWarnings False

DoCmd.OpenQuery "appCarePlanProblem", acNormal, acEdit
DoCmd.OpenQuery "appCarePlanOutcome", acNormal, acEdit
DoCmd.OpenQuery "appCarePlanEquipment", acNormal, acEdit
DoCmd.OpenQuery "appCarePlanInterventions", acNormal, acEdit

DoCmd.SetWarnings True
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70


Exit_cmdSelectTemplate_Click:
Exit Sub

Err_cmdSelectTemplate_Click:
MsgBox Err.Description
Resume Exit_cmdSelectTemplate_Click:
End Sub

The problem with this method is the user has to click the command button (cmdSelectTemplate) TWICE to run the above code and for the subforms to refresh with the data.

Is there anyway I can code this so the user only has to click the command button once, codes runs and subforms fill in with appropiate information?

Any assistance would be greatly appreciated.
 
Add the line
Me.YourSubForm.Requery
for each subform

after the append queries

Or put the TAG RequerySubForm on each subform ,and put this code in the after update event of your combo


Dim CTL As Control

For Each CTL In Me.Controls
If CTL.Tag Like "*" & "RequerySubForm" & "*" Then
CTL.Requery
End If
Next CTL


Cheers

Jimmy
 
Thanks Jimmy,
works a charm...

Note: like your Invoice System Program

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top