bradmaunsell
Programmer
I often use the follwing DAO routine with a form when I want to do something with a recordset (the recordset used as the datasource for a form). For example, I may want to append a transaction file with records shown on a subform I have open. This could be an accts payable subsidiary application where I want to append multiple line-item records to the general ledger application.
This following DAO code works fine.
Anybody know how to convert this to ADO?
Sub rs_qdf()
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set dbs = CurrentDb()
Set qdf = dbs.QueryDefs("cboGL_Rollups")
strSQL = qdf.SQL
strSQL = strSQL & "WHERE RupDesc = " & Forms!frmDE_Hdr!RupID
Set rs = dbs.OpenRecordset(strSQL)
Do Until rs.EOF
MsgBox rs!RupDesc
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
dbs.Close
Set dbs = Nothing
End Sub
**********************************************************
FYI: Unrelated to above question but just so you can see how I handle a "regular" ADO recordset. This is the routine I often use for various ADO recordset processing.
Sub ADO_Recordset()
Dim rs As New ADODB.Recordset
Dim strSQL As String
Set rs = New ADODB.Recordset
strSQL = "SELECT tblGL_Accts.AcctID, tblGL_Accts.AcctDesc FROM tblGL_Accts WHERE tblGL_Accts.AcctID < 20000"
rs.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic, adCmdText 'strSQL Data Source
Do Until rs.EOF
MsgBox rs!AcctDesc
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub
Thanks,
Brad
South Burlington, Vermont
This following DAO code works fine.
Anybody know how to convert this to ADO?
Sub rs_qdf()
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set dbs = CurrentDb()
Set qdf = dbs.QueryDefs("cboGL_Rollups")
strSQL = qdf.SQL
strSQL = strSQL & "WHERE RupDesc = " & Forms!frmDE_Hdr!RupID
Set rs = dbs.OpenRecordset(strSQL)
Do Until rs.EOF
MsgBox rs!RupDesc
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
dbs.Close
Set dbs = Nothing
End Sub
**********************************************************
FYI: Unrelated to above question but just so you can see how I handle a "regular" ADO recordset. This is the routine I often use for various ADO recordset processing.
Sub ADO_Recordset()
Dim rs As New ADODB.Recordset
Dim strSQL As String
Set rs = New ADODB.Recordset
strSQL = "SELECT tblGL_Accts.AcctID, tblGL_Accts.AcctDesc FROM tblGL_Accts WHERE tblGL_Accts.AcctID < 20000"
rs.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic, adCmdText 'strSQL Data Source
Do Until rs.EOF
MsgBox rs!AcctDesc
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub
Thanks,
Brad
South Burlington, Vermont