Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Data from One Suform to Another

Status
Not open for further replies.

kopy

Technical User
May 30, 2002
141
0
0
US
I'm fairly new at using VBA with recordsets. I'm trying to copy the data from one subform to another. The code I've written so far only moves the first record or selected record to the destination subform.

Any help will be greatly appreciated. Thanks, Kopy.

Here's my code:
===========================================================
Private Sub Command55_Click()

Dim rst As DAO.Recordset, sfrm As Form, sfrm1 As Form

Set sfrm = Forms![frmQuotes]![subUnionOperations].Form
Set rst = sfrm.RecordsetClone

Set sfrm1 = Forms![frmQuotes]![tblQuoteOps subform].Form
Set rst1 = sfrm1.RecordsetClone


If rst.RecordCount >= 1 Then
rst.MoveFirst
End If

Do
rst1.AddNew

Me![tblQuoteOps subform].Form![txtOperationNumber] = Me![subUnionOperations].Form![txtOperationNumber]
Me![tblQuoteOps subform].Form![txtType] = Me![subUnionOperations].Form![txtType]
Me![tblQuoteOps subform].Form![cboDesc] = Me![subUnionOperations].Form![cboDesc]
Me![tblQuoteOps subform].Form![txtSetUpTime] = Me![subUnionOperations].Form![txtSetUpTime]
Me![tblQuoteOps subform].Form![txtRunTime] = Me![subUnionOperations].Form![txtRunTime]

rst.MoveNext
Loop Until rst.EOF

End Sub
 

If rst.RecordCount = 0 Then
MsgBox "No Records, so quit"
Exit Sub
End If

rst.MoveFirst

Do While Not rst.EOF
...
(do your stuff here)
...
rst.MoveNext
Loop



Alan J. Volkert
Fleet Services
GE Commercial Finance Capital Solutions
(World's longest company title)
Eden Prairie, MN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top