VBA6 Open a Form
FROM Form_frmOpener2 Class Module

Option Compare Database

Sub LoadOrderDetailsRecordset2()
Dim rst1 As ADODB.Recordset

'Open shippers table
   Set rst1 = New ADODB.Recordset
   rst1.CursorLocation = _    
      adUseClient
   rst1.CursorType = adOpenKeyset
   rst1.LockType = _ 
      adLockOptimistic
   rst1.MaxRecords = _
      Form_frmOpener2.txtRecordLimit
   rst1.Open "[Order Details]", _
      CurrentProject.Connection, , , _
       adCmdTable

'Name form to open and specify 'recordsource
   DoCmd.OpenForm _ 
      "frmOrderDetails"
   Set Forms("frmOrderDetails")._
      Recordset = rst1

End Sub

Private Sub Form_Activate()
   
'Set the default MaxRecords value
   Me.txtRecordLimit = 8000

End Sub

Private Sub _    
   cmdOpenRecordset_Click()

'Turn on hour glass while recordset
'loads to local cache
   DoCmd.Hourglass True
   LoadOrderDetailsRecordset2
    
'Turn off hour glass
   DoCmd.Hourglass False
    
End Sub

Private Sub _
   cmdOpenRecordSource_Click()
    
'OpenForm method without any 
'parameters opens form to default 'recordsource
   DoCmd.OpenForm _ 
      "frmOrderDetails"
   Forms("frmOrderDetails")._
      RecordSource _
      = "[Order Details]"

End Sub

FROM Form_frmOrderDetails Class _ 
   Module

Option Compare Database

Private Sub Form_Load()

'Set MaxRecords to textbox 
'value on frmOpener2
   Me.MaxRecords = _
      Form_frmOpener2.txtRecordLimit
   Me.Requery

End Sub

Private Sub cmdReturn_Click()

'Return to calling form and 
'close current form
   DoCmd.OpenForm "frmOpener2"
   DoCmd.Close acForm, _    
      "frmOrderDetails"

End Sub


Listing 1 This selection of event procedures for opening a form is based on setting either its RecordSource or Recordset property. The procedures also manage the maximum number of records a form will download from MSDE or SQL Server based on a user-specified limit or a default value of 8,000.