Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

updating with recordsets

I have a table with query names and need to populate rowcounts.
Using a record set, I want to get the query name from the table, put it in a variable, use that variable in a dlookup query, and then use the results from the dlookup query to update a field for the current record in the record set. Can someone modify the code below to do this?

function get_records(table as string)
Dim rst As DAO.Recordset
Dim parsql As String
Dim parrecords As String

Set rst = CurrentDb.OpenRecordset(table)
Do While Not rst.EOF
parsql = rst("rptsql")

[I need to add something here to use parsql in a dlookup query]
parrecords=dcount("[ID]",'" & parsql & "'")
[I need to add something here to update the rptrows field in this recordset with the value returned by the dlookup query above.]

rst.MoveNext
If rst.EOF Then Exit Do
Loop

rst.Close
Set rst = Nothing
[976 byte] By [mdm0475] at [2007-11-11 8:09:24]