Avatar of shambalad
shambalad
Flag 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

Microsoft Access

Avatar of undefined
Last Comment
Jim Dettman (EE MVE)

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
peter57r

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Jim Dettman (EE MVE)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes