Contact us
LISTING 2.  Code to Programmatically Base a Form on a Custom Recordset

Sub openForm()
Dim rst1 As ADODB.Recordset

'Establish a local recordset and populate it with values
'can override property sheet settings
    Set rst1 = New ADODB.Recordset
    rst1.CursorLocation = adUseClient
    rst1.Open "Select * From employees", _
    CurrentProject.Connection, adOpenKeyset, _
    AdLockPessimistic, adCmdText

'Open the form
    DoCmd.openForm "frmemployees"

'Assign recordset to the open form; can override a
'setting on the property sheet
    Set Forms("frmemployees").Recordset = rst1

End Sub