Link to home
Start Free TrialLog in
Avatar of shambalad
shambaladFlag for United States of America

asked on

Using RecordSource vs Recordset in Forms

Below are two procedures for defining the data associated with a form. One uses the form's RecordSource property, the other uses the form's Recordset property.
Are there any distinct advantages to using one procedure over the other? What are the implications of changing a form so that the data is defined using the recordset property as opposed to the recordsource property?
I am in the midst of writing an application (2007 - accdb) where the tables and queries may reside in either the local or a remote database (I am not using logical files). In order to accomplish this, I need to control the opening of the recordsets, which, in turn, means that I find myself switching from using the form recordsource property to the form recordset property.
I'm just trying to make sure I don't engender some unexpected consequences in making this modification.
Thanks,
Todd
Private Sub UseRecordSource()
   Dim strSQL As String
   strSQL = "SELECT A,B,C From Table1 WHERE A = '10' ORDER BY B"
   Me.RecordSource = strSQL
End Sub

Private Sub UseRecordSet()
   Dim rst As DAO.Recordset
   Dim db As DAO.Recordset
   Dim strSQL As String
   strSQL = "SELECT A,B,C From Table1 WHERE A = '10' ORDER BY B"
   Set db = CurrentDb
   Set rst = db.OpenRecordset(strSQL)
   Set Me.Recordset = rst
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial