Adding a row to a subform via code

M

MB

I have an order form that contains a credit card number for payment. Each
order may have more than 1 transaction with the same card, so there is a
order.payments.subform.

I have a button that opens a new create.charge.form that handles the actual
transaction and returns the success/fail, authorization code, etc.

I then add this information to a new row in the order.payments.subform (from
the create.charge.form )

Originally I was creating a new recordset, adding a new record, updating the
fields, updating the records and then refreshing the subform.

Worked great, but slow.

So now I am writing to the subform directly,
Forms![orders]![order_paymentsSub].Form![order_id] = orderId, etc, etc. Much
faster.

Works fine on the first transaction, but I can't figure out how to add a new
one.

Have tried docmd, recordset.addnew (can provide details if needed). I know
I'm close!!!

Thanks

MB
 
S

Steve Schapel

MB,

Do you mean that the create charge form is unbound? I don't quite
understand why you are not entering your new charge directly into the
order payments subform, but then I don't know much about your database.

Here's one idea to consider...

CurrentDb.Execute "INSERT INTO OrderPayments ( orderID, etc )" & _
" VALUES ( " & Me.orderID & ", " & etc. & " )"
 

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