RDO recordset Loop

jmeek

Registered User.
Local time
Today, 01:57
Joined
Aug 16, 2005
Messages
38
Can somebody please help me create a loop from the
following code. At the moment the code only adds
one record at a time from the subform table.

Private Sub Command0_Click(0)

Dim rdoConn As RDO.rdoConnection
Dim rdoEnv As RDO.rdoEnvironment
Dim rdoEnvs As RDO.rdoEnvironments
Dim rdoRS As RDO.rdoResultset
Dim strsql As String

Set rdoEnvs = rdoEngine.rdoEnvironments
Set rdoEnv = rdoEnvs(0)

rdoEnv.CursorDriver = rdUseServer

Set rdoConn = rdoEnv.OpenConnection("", rdDriverNoPrompt, False, "DSN=CNL;UID=LN;PWD=")

strsql = "SELECT * FROM CustPriceList"
Set rdoRS = rdoConn.OpenResultset(strsql, rdOpenKeyset, rdConcurLock)

rdoRS.AddNew

rdoRS("CustCode") = Me.sfAddCodes.Form.Cust
rdoRS("CodeID") = Me.sfAddCodes.Form.Code
rdoRS("Price1") = Me.sfAddCodes.Form.NewPrice1

rdoRS.Update

rdoRS.Close
rdoConn.Close
rdoEnv.Close

End
End Sub
 
That's because the subform can have only a single current record at a time.

Rather than doing this in a code loop, use an append query (it is much more efficient) that selects the rows you want from one table and appends them to another. Run the append query from a button on the parent form.
 

Users who are viewing this thread

Back
Top Bottom