Addig a record to a subform upon quitting a Form

S

Stephen

I have an Orders Database.
Upon quitting an Order (Leaving the Orders Details Subform) I want to
automatically add 1 last record (Order Detail) to the Order.

I've added the following code, but it doesn't work. Any help would be great.


Private Sub Order_Details_Subform_Exit(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec

Me![ProductID] = "zzzz Fuel Surcharge"
' **** THE FOLLOWING LINES LOOK UP PRICES, COMMISSIONS, ETC ****
Me![UnitPrice] = Me![ProductID].Column(3)
Me![UnitofMeasure] = Me![ProductID].Column(4)
Me![UnitCost] = Me![ProductID].Column(6)
Me![Order Details.CommRateLine] = Me![ProductID].Column(9)

End Sub
 
T

tynerr

Put a "Close" button on the form. Use your code (below) as the first part of
the
<Private Sub MyButton_Click()> statements. You also must add a
<DoCmd.Runcommand accommand.saverecord> statement after your code. When all
these are there then allow the

<DoCmd.Close> statement
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top