Solved

Openrecordset parameters

Posted on 1998-04-23
2
228 Views
Last Modified: 2012-05-04
hi, there
I like to know some details example about how to use the openrecordset(parameters). In what conditions I should use dbopendynaset, table, snapshot, and forwardonly, readonly, etc.
I have read the VB help file. but I want to know some real world examples.
Could anyone give me some hints?

ny971181
0
Comment
Question by:ny971181
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 30 total points
ID: 1428026
First of all, the dynaset, table, and snapshots.

Snapshots are for read-only recordsets.  They are quicker to load so if you don't need to edit the data, use this.

Dynasets are editable recordsets.  If you need to edit the data use this.

Tables are somewhat like dynasets, but are more limited in the methods to use (such as searching for a particular value).  It is preferred to use dynasets instead of this.

Forward only, allows for a faster loading of the recordset.  Snapshots are always opened as forward only.  If you don't need to move back and forth through the recordset, use this.

Set rsTable = dbData.OpenRecordset(sTable, dbOpenForwardOnly)
is the same as
Set rsTable = dbData.OpenRecordset(sTable, dbOpenDynaset, dbForwardOnly)

Readonly - If you open a dynaset as read-only, you are in effect opening a snapshot.

Now for examples:

To open a recordset for general uses:
  Set rsTable = dbData.OpenRecordset(sTable, dbOpenDynaset)
This will allow moving though the recordset forward and backward.  It will also allow for adding data and editing existing data.

To open a recordset for reading only, to display a list of available data, for example:
  Set rsTable = dbData.OpenRecordset(sTable, dbOpenSnapshot)
You would use this for something like loading a listbox with data, or creating a report.

If you will do nothing bu add new data to a recordset:
  Set rsTable = dbData.OpenRecordset(sTable, dbOpenDynaset, dbForwardOnly)
This will allow for adding data, but won't allow to seek an existing value.

There are many variations of the options available for OpenRecordset.  This is but a small sampling.
Might I suggest you look into one of the many books available for VB with emphesis on database programming?
0
 
LVL 1

Author Comment

by:ny971181
ID: 1428027
hi, Thank you for your detailed explanation.
That helps a lot.
I did look at some books b4, but none summarize the topic. So I lost them easily.

But thank you again.

ny971181

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question