Using RecordSource vs Recordset in Forms

shambalad
shambalad used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
If you are using dao then I don't think there is any practical difference between the two.  You would have a potential marginal difference due to the time the rs was created compared with when the recordsource query was actioned.  But for dao, changing one changes the other (at least, that's what I understand).

The recordset property can be used to assign ado recordsets, and in that context, disconnected recordsets, to a form and this is can be useful in specific circumstances, although not common.
Jim Dettman (EE MVE)President / Owner
Most Valuable Expert 2017
Most Valuable Expert 2012
Commented:
You might want to have a look at this:

How to bind Microsoft Access forms to ADO recordsets
http://support.microsoft.com/kb/281998

  In general, you gain more control over what's going on.  For example, by using the RecordSet property and binding to a recordset you've opened, you could use transactions in conjunction with the form.

Jim.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial