You can either hard code it in, since they dont want any changes to the
db the object names should stay the same, or use the smae methods to
access a form and/or controls to get to the forms recordsource property.


VB Code:
  1. Option Explicit
  2. 'Add reference to MS ActiveX Data Objects 2.x Library
  3. 'Add reference to MS Access xx.Object Library
  4. Private moCnn As ADODB.Connection
  5. Private moRs As ADODB.Recordset
  6. Private moApp As Access.Application
  7.  
  8. Private Sub Command1_Click()
  9.    
  10.     Dim oForm As Access.Form
  11.     Dim sRecordSource As String
  12.     Dim sFilter As String
  13.     Dim sSQL As String
  14.    
  15.     DoCmd.OpenForm "Form1", acDesign, , , acFormReadOnly, acHidden
  16.     Set oForm = moApp.Forms.Item(0)
  17.     sRecordSource = oForm.RecordSource
  18.     If oForm.FilterOn = True Then
  19.         sFilter = oForm.Filter
  20.     Else
  21.         sFilter = vbNullString
  22.     End If
  23.     MsgBox sRecordSource & vbNewLine & sFilter
  24.     'More to follow...
  25.    
  26. End Sub
  27.  
  28. Private Sub Form_Load()
  29.     Set moCnn = New ADODB.Connection
  30.     moCnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\RobDog888.mdb;Persist Security Info=False"
  31.     moCnn.Open
  32.     Set moApp = New Access.Application
  33.     moApp.Visible = True
  34.     moApp.OpenCurrentDatabase "D:\RobDog888.mdb"
  35. End Sub