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 All open Forms when necessary

Functions

How to Refresh All open Forms when necessary

by  Zion7  Posted    (Edited  )
My users like to see Audit forms,
reflect any changes in the data, right away.

If they're toggling back & forth between an Editable Form,
and an audit form, they're feel their edits are not being saved,
or the Audit form is not Computing correctly,
if the changes are not updateing, instantaneously.

And So, I came up with this,
iterate through all the open forms in the DBase,
iterate through the pertinant controls, of each open form,
and requery each control.

So from each relevant form, that has an audit form,
either in the control afterUpdate event,
or the form afterUpdate event,
I call the "refreshForms" procedure.




Private Sub txtGrandTotal_AfterUpdate()
Me.Refresh
Call RefreshForms
End Sub

_____________________________________________

Private Sub Form_AfterUpdate()
Me.Refresh
Call RefreshForms
End Sub


_________________________________________________

Sub RefreshForms()
10 On Error GoTo xxx

Dim x As Integer
20 For x = 0 To Forms.Count - 1
30 Call RefreshForm(Forms(x))
40 Next

xx:
50 Exit Sub
xxx:
60 MsgBox err & vbcrLf & Error$
70 Resume xx
End Sub

________________________________________________________

Sub RefreshForm(frmForm As Form)
10 On Error GoTo xxx

Dim x As Integer
20 With frmForm
25 .Recalc
30 For x = 0 To .Controls.Count - 1
40 Select Case .Controls(x).ControlType
Case acComboBox, acListBox, acSubform
50 .Controls(x).Requery
60 End Select
70 Next
80 .Refresh
90 End With
xx:
100 Exit Sub
xxx:
If err.Number = 2478 Then
Resume Next
Else
60 MsgBox err & vbcrLf & Error$
70 Resume xx

End If
End Sub

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top