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:
Option Explicit 'Add reference to MS ActiveX Data Objects 2.x Library 'Add reference to MS Access xx.Object Library Private moCnn As ADODB.Connection Private moRs As ADODB.Recordset Private moApp As Access.Application Private Sub Command1_Click() Dim oForm As Access.Form Dim sRecordSource As String Dim sFilter As String Dim sSQL As String DoCmd.OpenForm "Form1", acDesign, , , acFormReadOnly, acHidden Set oForm = moApp.Forms.Item(0) sRecordSource = oForm.RecordSource If oForm.FilterOn = True Then sFilter = oForm.Filter Else sFilter = vbNullString End If MsgBox sRecordSource & vbNewLine & sFilter 'More to follow... End Sub Private Sub Form_Load() Set moCnn = New ADODB.Connection moCnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\RobDog888.mdb;Persist Security Info=False" moCnn.Open Set moApp = New Access.Application moApp.Visible = True moApp.OpenCurrentDatabase "D:\RobDog888.mdb" End Sub





Reply With Quote