AutoUpdate a Subform

Robbyp2001

Registered User.
Local time
Tomorrow, 02:47
Joined
Oct 8, 2011
Messages
143
In a stock order database, I have a main form [mainform] which containes the customer name and ID based om an underying table [OrderTbl]. Below this is a subform StockSub1. This is based on the underlying table [ordertbl] and contains order details, Item classification, Item description, order date and number ordered. So far so good.

Below this is another continuous subform [Stocksub2] that holds a hsitory of the orders made by the above customer.

What I am trying to achieve is the records in [Stocksub2] update immediately another order is made.

If I move away from the record and back again, or press F5 to refresh, I can see the list, so they are there. However, I need this list to be updated either at the click of a button on [StockSub1] or after updating the last field on [StockSub1].

I have tried trawling for some code to do this but after having tried everything, I still cannot get this to update.

Could someone be kind enough to help me with this? I have a attached a copy of what I have so far.

Rob
 

Attachments

Put code on your subform1, AfterUpdate :

Private Sub Stocksub1_AfterUpdate()
Me.Parent!Stocksub2.Requery
End Sub
 
in addition to other suggestions,

although it looks like you made a valid attempt on your own, all the code in your example can be deleted.

in your first subform command button try
Code:
Private Sub Command6_Click()

    If Not IsNull(Me.Combo0) And Not IsNull(Me.Combo2) And Not IsNull(Me.Numentered) Then    ' Check if all three fields enterred

        Me.Dirty = False   ' force a save of the data

        Me.Recordset.AddNew    'move Stocksub1 to a new record

        Parent.Stocksub2.Requery    ' requery the other subform

    Else

        MsgBox "Missing Info"  ' msgbox if there is missing info

    End If

End Sub
 
Superb Moke! Works a treat. Many thanks to you, to Paul and to Arnelgp. Once again the experts have come to my aid!!!!!
 

Users who are viewing this thread

Back
Top Bottom