Hi Friends!
Can anyone help on writing a Insert code with looping.
I have designed a Invoice form with subform and using Insert code for enter the data from forms to tables as per following code.
But in that need to set looping for subform multiple records.
I'm not well to writing VBA code, please can anyone help on this.
Please find below details If require.
Main from : frmSE_A
Subform : frmSE_B
Main form Inputs: txtInvoiceNo, txtInvoiceDt, txtInvoiceMode, txtCustomer, txtPromoterAddress, txtWorkArea, txtProDisc, txtAddDisc, txtGTotal, txtRemarks
Subform Inputs: txtItem, txtQty, txtMRP, txtLP
Thanks,
Sandhya
Can anyone help on writing a Insert code with looping.
I have designed a Invoice form with subform and using Insert code for enter the data from forms to tables as per following code.
Code:
Private Sub btn_Save_Click()
Dim i As Integer
Dim frmSE_B As Recordset
Set frmSE_B = frmSE_B
CurrentDb.Execute "INSERT INTO SE_A(Inv_No,Inv_Date,Inv_Mode,Customer,Pro_Add,Pro_Work,Pro_Disc,Add_Disc,G_Total,Remarks) VALUES('" & txtInvoiceNo & "','" & txtInvoiceDt & "','" & txtInvoiceMode & "','" & txtCustomer & "','" & txtPromoterAddress & "','" & txtWorkArea & "','" & txtProDisc & "','" & txtAddDisc & "','" & txtGTotal & "','" & txtRemarks & "')"
For i = 0 To frmSE_B - 1 Step 1
CurrentDb.Execute "INSERT INTO SE_B(Item_ID,Qty,MRP,LP) VALUES('" & frmSE_B.txtItem(0, i) & "','" & frmSE_B.txtQty(1, i) & "','" & frmSE_B.txtMRP(2, i) & "','" & frmSE_B.txtLP(3, i) & "')"
Next
MsgBox "Successfully done", vbInformation, "Sales"
End Sub
But in that need to set looping for subform multiple records.
I'm not well to writing VBA code, please can anyone help on this.
Please find below details If require.
Main from : frmSE_A
Subform : frmSE_B
Main form Inputs: txtInvoiceNo, txtInvoiceDt, txtInvoiceMode, txtCustomer, txtPromoterAddress, txtWorkArea, txtProDisc, txtAddDisc, txtGTotal, txtRemarks
Subform Inputs: txtItem, txtQty, txtMRP, txtLP
Thanks,
Sandhya