Uisng Access 2007, with libraries for DAO:
- Microsoft Office 12.0 Access database engine Object Library
- Microsoft Jet and Replication Objects 2.6 Library
On a form, I've put radio buttons/option group to select two different modes.
Mode1 - browse/edit all records in a table, sorted by ID (i.e.Primary Key). As a row is edited and saved, the userid and date/time-saved are both stored into two extra columns on the row. Then use Back and Next buttons to move to previous/next row.
Mode2 - edit only rows which have not already been processed ( i.e. userid and date/time-saved columns are NULL). When switching from Mode1 to Mode2, note current position, then when switched to Mode2, position goes to FIRST row where ID.Mode2 > ID.Mode1 (i.e. the "next" unedited row.)
I've currently implemented this with one recordset. Switching to Mode2 is done with:
Dim sSQL As String
sSQL = "([USER_EDIT] IS NULL) AND ([USER_SAVE] IS NULL)"
Switching back to Mode1 is done with:
Me.FilterOn = False
Using this code, wherever I'm positioned in the recordset becomes the beginning of the sorted subset (i.e. any un-saved rows with [ID] < currentID will not appear in the rows for Mode2.) In addition, the sort order changes completely .. can't really identify if there is one.
It would seem that using two recordsets (rst1 and rst2), using the existing definition as is for rst1, then adding the sort and filter criteria to rst1 and create a second recordset via
set rst2 = rst2.OpenRecordset
should work.. but I can't get the last statement to work... it says I have missing parameters for the OpenRecordset method.
The other thing that bothers me about this code is that I'm using a DoCmd.ApplyFilter to do the select, but then do a Me.FilterOn to reverse the operation. What's DoCmd got to do with it, and what is "Me" referring to when it's used to turn off the filter?
Being new to Access VBA, I'm not clear on how these recordsets relate to the form. I see what appears to be a "default" recordset named RECORDSET, and somehow the fields on the form are bound to the columns in this recordset. At a conceptual level, if I could "swap" the recordsets bound to the form, then I could switch back and forth based on the desired mode.
Since conceptual does not match practical in many instances, what's the best way to get this done?