![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Dear All, I want to copy multiple records from one table to another with specific field. I have written code. It is copying only first record. I use the loop command also. My code are as follows. Please anybode solve my problem. Thanks in advance. Private Sub CboMemoref_AfterUpdate() Dim db As Database Dim rs As Recordset, rs1 As Recordset, rs2 As Recordset Dim vReqNo As Integer Set db = CurrentDb() Set rs = db.OpenRecordset("select * from tblMechRequestDetails where val(RequestNo) = '" & Val(Me.RequestNo) & "'") Set rs2 = db.OpenRecordset("tblQuotationDetailsMech", dbOpenDynaset) Do While Not rs.EOF vReqNo = rs.RecordCount rs.MoveLast If rs!RequestNo = Me.RequestNo And vReqNo > 0 Then rs2.AddNew rs2!QuotationNo = Me.QuotationNo rs2!RequestNo = rs!RequestNo snip rs2!Quantity = rs!Quantity rs2.Update Exit Do End If rs.MoveNext Loop Set rs = Nothing Set rs2 = Nothing Set db = Nothing End Sub Stop with the recordsets already. A query would make short work of this: |
![]() |
| Thread Tools | |
| Display Modes | |
| |