473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Binding Form to Query or Recordset?

124 100+
I'm working in an Access 07 project linked to SQL Server db. Right now I'm trying to determine which is better performance wise: binding a form's recordsource to a query or a recordset in the OnOpen event?

Here's an example. I have a form's recordsource as a query:

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM StdDegReqClass WHERE StdDegReqDiscId = [Form]![Control] ORDER BY SortOrder
  2.  
Or I bind it to a recordset in the On Open event:

Expand|Select|Wrap|Line Numbers
  1.     Dim cn As New ADODB.Connection
  2.     Dim rs As ADODB.Recordset
  3.     Dim lngStdDegReqDiscId As Long
  4.  
  5.     cn.Open CurrentProject.Connection
  6.  
  7.     Set rs = New ADODB.Recordset
  8.     lngStdDegReqDiscId = Forms!f_StdDegReqDisc.txtStdDegReqDiscId
  9.  
  10.     rs.Open "SELECT * FROM StdDegReqClass WHERE StdDegReqDiscId = " & lngStdDegReqDiscId & " ORDER BY SortOrder", cn, _
  11.         adOpenKeyset, adLockOptimistic
  12.  
  13.     Set Me.Recordset = rs
  14.  
  15. Exit_Procedure:
  16.     cn.Close
  17.     Set rs = Nothing
  18.     Exit Sub
  19.  
I've read that one way to improve performance is to limit the data by using recordsets because when a form is tied to a table or query Access issues a command to the db server to modify the records and retrieve the data again every time the object is opened or modified. While this makes sense I guess I'm looking for a second opinion on the topic. Your advice is much appreciated!
Jul 9 '10 #1

✓ answered by nico5038

When you use a SELECT query for your form, the data will indeed be "read-only".
To maintain updates You'll have to create your own UPDATE query. So for the most effective way you should have to switch to "unbound" forms and handle updates and deletes by code. All things come with a price.....

Nic;o)

3 5872
nico5038
3,080 Expert 2GB
The best way is to use a "Pass-Through" query.
This will be send to the database engine and only the filtered result will be sent back. When using an Access query, Access will first fetch all rows before filtering....

Nic;o)
Jul 9 '10 #2
bullfrog83
124 100+
@nico5038
I've read that pass-through queries are not updatable (they return read-only data) and so are not useful for forms. Is that your understanding?
Jul 9 '10 #3
nico5038
3,080 Expert 2GB
When you use a SELECT query for your form, the data will indeed be "read-only".
To maintain updates You'll have to create your own UPDATE query. So for the most effective way you should have to switch to "unbound" forms and handle updates and deletes by code. All things come with a price.....

Nic;o)
Jul 9 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ano1optimist | last post by:
Has anyone had success with using a command collection with parameters to run a stored procedure from sql server? I'm frustrated and have been spending way too much time trying to make this work. ...
2
by: Lyn | last post by:
Hi, I am opening a form in Continuous mode to list the records from a recordset created in the calling form. The recordset object is declared as Public and is set into the new form's Recordset...
1
by: ZRexRider | last post by:
Hello, I have an MS-Access 2003 (ADP) project that uses SQL2000. I have a form that displays all "OPEN" items associated with a particular user. While viewing this form the user can click a...
9
by: sajuk | last post by:
Hi, any ideas for this problem would be appreciated. - I am coding to enable me to use a receipt printer as the Access Report functionality does not give the correct working function. - I have...
3
by: sphinney | last post by:
I have a form with a subform. The code of the parent form alters the "Recordsource" property of a subform. Altering this property automatically triggers the subform to requery a table that has lots...
11
by: fieldling | last post by:
I have a query which I view through a form. Due to problems with the label wizard printing to a dot-matrix printer I have some code to print out a single label when a command button is clicked. This...
8
by: glamster7 | last post by:
Ok folks its Friday & I'm feeling a bit thick (also not very well). I have a form Salonmanagerdetail wich allows the user to enter the following details Stylist_Id,Stylist_Name,Group_Name &...
1
by: charles.kendricks | last post by:
I have a form that is used to display patient records. It's default Recordset is set to a query which shows only current clients. I want to use an option box on the form to force the form to use...
1
by: JDCO | last post by:
I have a database I've created to send out tailored reports to recipients on email. This was done using a module (which creates the outlook session etc and has all the handling info etc on it) and a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.