Update once form input entered

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All

I have a number of tables, queries, forms and reports set
up. Users will firstly enter customer details into one
form then enter their order and payment method into 2
other forms. These orders should then be viewed on
another form (looks like a calendar).

If I have all 4 forms open each piece of new data entered
(eg. new customer name, new order # etc) does not flow
through to the other forms. How can I achieve this
without having to open and close forms all day???

Please help
Thanks
 
Use the AfterUpdate and AfterDelConfirm events of all forms to notify the
other forms about the changes.

Part of the struggle is that at the time you are developing each form, you
don't know which other forms or combo boxes might depend on it. What we do,
therefore, is to create a function in a general module, call it from all the
forms we create, and actually fill in the details of the function once all
forms in developed and you know which ones depend on which other ones.

Every form's AfterUpdate event procedure contains:
Call NotifyCombos(Me)
and every form's AfterDelConfirm event procedure contains:
Call NotifyCombos(Me, Status)

In the standard module, is the function that sorts it out with a huge Select
Case structure. This makes it a big function, but we find it easier to
maintain.

Public Function NotifyCombos(frmSource As Form, _
Optional iStatus as Integer = acDeleteOK)
If iStatus = acDeleteOk Then
Select Case frmSource.Name
Case "frmCustomer" 'This is the form that was updated.
If IsLoaded("frmOrder") Then 'This is the one that needs
requerying.
Forms("frmOrder")!CustomerID.Requery
End If
Case "frmOrder"
'requery whatever
Case Else
Debug.Print "NotifyCombos() not handling " & frmSource.Name
End Select
End If
End Sub

Note: Copy the IsLoaded() function from the Utility module in Northwind, or
in A2000 and later use:
If CurrentProject.AllForms("frmCustomer").IsLoaded Then
 
Back
Top