Access 2007 VBA Programmer’s Reference phần 9 doc

115 304 0
Access 2007 VBA Programmer’s Reference phần 9 doc

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Property DataType Description Dialect GUID Contains a GUID that represents the dialect of the command text or stream. Name String Identifies the Command object as a method on the associated Connection object. NamedParameters Boolean Indicates whether parameter names are passed to the provider. Prepared Boolean True if the provider should save a compiled ver- sion of a Command before execution. State Long Value that represents if the Command object is open, closed, or in the process of connecting, executing, or retrieving information. Methods of the Command Object Methods of the Command objects are used to work with a particular command that will be executed on the Connection object. To execute a Command object, just call it by its Name property on the associated Connection object. Method Description Cancel Cancels the execution of an asynchronous call before it has completed. CreateParameter Creates a parameter for the Command object with the specified settings, which are five optional parameters: Name, Type, Direction, Size, and Value. Execute Executes the particular command stored in the CommandText property. Collections of the Command Object Collection Description Parameters Contains all the Parameter objects used for stored queries and stored procedures. Properties Contains all the Property objects for the current command object. 878 Appendix E: ADO Object Model Reference 47033bapp05.qxd:WroxProgRef 3/30/07 12:29 AM Page 878 Parameters Collection The Command object has a Parameters collection associated with it that contains all of the Parameter objects of the Command object. The actual Parameters collection does not contain any properties or col- lections, only methods. Methods of the Parameters Collection There are exactly three methods for the Parameters collection. They are described in the following table. Method Arguments Description Append Parameter object Used to add a Parameter object to the collection. Refresh None Updates all of the Parameter objects in the collec- tion with the latest information from the provider. Delete Index Deletes a Parameter object from the collection. The Index value is either the name or ordinal posi- tion of the Parameter in the collection. Properties of the Parameter Object Each Parameter object in the Parameters collection contains the actual data for the parameter. The fol- lowing table describes the various properties of the Parameter objects. Property DataType Description Attributes Long A read/write property that is the sum of any one or more ParameterAttributesEnum val- ues. The default value is adParamSigned. Direction ParameterDirectionEnum Indicates if the Parameter represents an input parameter, an output parameter, an input and an output parameter, or if the parameter is the return value from a stored procedure. Name String Sets or returns the name of the Parameter. NumericScale Byte Sets or returns a byte value that indicates the number of decimal places to which numeric val- ues are resolved. Precision Byte Indicates the degree of precision for a Parameter object. This sets or returns a Byte field to represent the maximum number of dig- its used to represent values. Table continues on the next page 879 Appendix E: ADO Object Model Reference 47033bapp05.qxd:WroxProgRef 3/30/07 12:29 AM Page 879 Property DataType Description Size Long Indicates the maximum size in either bytes or characters of the Parameter object. Type DataTypeEnum Indicates the data type of the Parameter. Value Variant The default property value. Sets or returns the value of the Parameter. Method of the Parameter Object The only method available for the Parameter object is AppendChunk. It simply appends data to the Parameter object. Use the CreateParameter method of the Command object to create a Parameter with a specific name and properties. Then use the Append method to add the newly created Parameter to the Parameters collection. Method Description AppendChunk Adds a Parameter to the Parameters collection. Collections of the Parameter Object There is exactly one collection for the Parameter object — Properties. Collection Description Properties Contains all the Property objects for the current Parameter object. Recordset Object The Recordset object is used to read or manipulate data in an ADO data source. It represents the set of records from a table or the results of an executed command. All recordsets consist of records (rows) and fields (columns). Depending on the functionality supported by the provider, some Recordset methods or properties may not be available. Properties of the Recordset Object The Recordset object has a variety of properties and methods you’ll use in your programming. The fol- lowing table describes the properties. 880 Appendix E: ADO Object Model Reference 47033bapp05.qxd:WroxProgRef 3/30/07 12:29 AM Page 880 Property DataType Description AbsolutePage Long Identifies the page the current record of the Recordset is on. AbsolutePosition Long Identifies the position of the current record in the Recordset. ActiveCommand Variant Pointer to the Command object that created the Recordset. ActiveConnection String or Connection Specifies the Connection object used to retrieve the Recordset. BOF Boolean True if you’re currently at the beginning of the file, the position before the first record. Bookmark Variant Allows you to return to a specific record in the Recordset. CacheSize Long The number of records ADO caches from the server. CursorLocation Long Lists whether the cursor service that maintain the results of the query is client-side or server-side. CursorType CursorTypeEnum Specifies the type of cursor used to access the query results (dynamic, keyset, status, for- ward-only). DataMember String Specifies which Recordset in the data source you’re referring to. DataSource Object Allows you to associate the Recordset with a data source. EditMode EditModeEnum Specifies the editing status for the current record. EOF Boolean True if you’re currently at the end of file, the position after the last record in your Recordset. Filter Variant Allows you to filter your Recordset for partic- ular values. Index String Controls the index currently applied in your Recordset. LockType LockTypeEnum Controls how the contents of the Recordset are locked and updated. MarshalOptions MarshalOptionEnum Specifies which records are transferred back to the server. Table continues on the next page 881 Appendix E: ADO Object Model Reference 47033bapp05.qxd:WroxProgRef 3/30/07 12:29 AM Page 881 Property DataType Description MaxRecords Long Long value representing the maximum number of records returned by the query. PageCount Long The number of pages in your Recordset. PageSize Long Specifies the number of records per page in the Recordset. RecordCount Long Long value representing the number of records in the Recordset. Sort String Allows you to specify a sort order in your Recordset. Source String or command String value or command object that contains the query string used for the Recordset. StayInSync Boolean True if the child record needs to be kept updated. State Long Returns the current state of the Recordset. Status RecordStatusEnum Stores the update status of the current record. There are two common properties used when working with a Recordset object. The first, and probably most important, is the Fields collection. This collection stores all of the fields that contain the results of a given query. The second is the Properties collection, a collection of dynamic properties associated with Recordset. Methods of the Recordset Object You’ll use a number of methods when manipulating your Recordset object as well. Those methods are listed in the following table. Method Description AddNew Adds a new record to the Recordset. Cancel Cancels the execution of an asynchronous query. CancelBatch Cancels pending changes in a Recordset that uses batch optimistic updates. CancelUpdate Cancels pending changes currently being edited. Clone Creates a new reference to the Recordset that allows navigation inde- pendently from the original Recordset. Close Closes the Recordset object and releases its contents. CompareBookmarks Compares two bookmarks in the same Recordset. 882 Appendix E: ADO Object Model Reference 47033bapp05.qxd:WroxProgRef 3/30/07 12:29 AM Page 882 Method Description Delete Deletes the current record in the Recordset. Find Searches the Recordset for a record based on the string criteria. GetRows Returns the record data in a two-dimensional Variant array. GetString Returns the record data in a String format. Move Moves the position of the current record. MoveFirst Moves to the first record in the Recordset. MoveLast Moves to the last record in the Recordset. MoveNext Moves to the next record in the Recordset. MovePrevious Moves to the previous record in the Recordset. NextRecordset Clears any previously existing records and returns the next Recordset. The record returned is the result of the next command in a compound com- mand statement. Open Opens the Recordset. Requery Re-executes the query that generated the Recordset. Resync Retrieves the current data for the records in the Recordset. Save Writes the Recordset contents to a file. Seek Searches the Recordset for a specific string. Supports Returns a Boolean value indicating whether the Recordset supports a particular type of functionality. Update Writes pending changes to the Recordset. UpdateBatch Submits pending changes in a Recordset that uses batch optimistic updating. Collections of the Recordset Object The Recordset object contains two collections: Fields and Properties. The Fields collection is useful for retrieving information about the fields contained in the Recordset object. Collection Description Fields Contains all the Field objects for the current data contained in the Recordset object. Properties Contains all the Property information for the Recordset object. 883 Appendix E: ADO Object Model Reference 47033bapp05.qxd:WroxProgRef 3/30/07 12:29 AM Page 883 Fields Collection The Fields collection contains all the Field objects of a Recordset or Record object. It allows you to retrieve information about the field as well as data within the field. The following sections describe the properties and methods for the Fields collection. There are no collections for the Fields collection. Properties of the Fields Collection The Fields collection supplies only two properties: Count and Item, which are detailed in the follow- ing table. Property DataType Description Count Long The number of Field objects in the Record or Recordset object. Item Field Identifies the position of the current record in the Recordset. Methods of the Fields Collection Methods for the Fields collection are described in the following table. Method Description Append Creates and adds a field object to the Fields collection. Update Finalizes any additions or deletions to the Fields collection. CancelUpdate Cancels any pending changes for a record. Delete Deletes a Field from the collection. Refresh Refreshes the Fields collection. Resync Resynchronizes the current record. Field Object The Fields collection contains Field objects. Each object represents an individual field within a Fields collection from an ADO Record or Recordset object. Properties of the Field Object The properties for the Field object are described in the following table. 884 Appendix E: ADO Object Model Reference 47033bapp05.qxd:WroxProgRef 3/30/07 12:29 AM Page 884 Property DataType Description ActualSize Long Returns the actual size of the value of the field. Attributes Long Describes certain characteristics of the field. DataFormat Object Can be used to format your data. DefinedSize Long Describes the defined size for the field. Name String Contains the name of the field. NumericScale Byte Number of digits allowed to the right of the decimal point for a numeric field. OriginalValue Variant Stores the original value for the field. Precision Byte Indicates the precision for numeric data. Status FieldStatusEnum Determines whether the field has been success- fully added to the collection. Type Byte Lists the data type for the field. UnderlyingValue Variant Lists the most recently retrieved value for the field. Value Variant Contains the field’s current value. Methods of the Field Object The Field object has two methods, which are detailed in the following table. These methods apply only to string or binary field types and may not be supported by all ADO providers. Method Description AppendChunk Allows data to be appended to a string or binary field type. GetChunk Allows retrieval of data from a string or binary field type. Collection of the Field Object The only collection of the Field object is the standard Properties collection. Collection Description Properties Contains all the property objects for the current Command object. 885 Appendix E: ADO Object Model Reference 47033bapp05.qxd:WroxProgRef 3/30/07 12:29 AM Page 885 Record Object The Record object represents a row from a Recordset or any object returned by a data provider. A Record object contains data from the row and allows the user to easily access that data. Properties of the Record Object The following table describes the properties associated with a Record object. Property DataType Description ActiveConnection Variant The Connection object used to retrieve the data for the Record object. Mode ConnectModeEnum Specifies the permissions for modifying the Record object. ParentURL String The Parent URL for the Record object. RecordType RecordTypeEnum Specifies the type of the Record object. Source Variant Specifies the source of the data contained in the Record object. State ObjectStateEnum Indicates the state of the Record object. Methods of the Record Object The Record object has seven methods, defined in the following table. Method Description Cancel Cancels an asynchronous action on the Record object. Close Closes an open Record object. CopyRecord Copies the Record object to another location. DeleteRecord Deletes the current record. GetChildren Retrieves the child data associated with the Record object. MoveRecord Moves the Record to another location. Open Opens an existing Record or creates a new Record. 886 Appendix E: ADO Object Model Reference 47033bapp05.qxd:WroxProgRef 3/30/07 12:29 AM Page 886 Collections of the Record Object The Record object has two collections, just like the Recordset object. These collections are described in the following table. Collection Description Fields Contains all the Field objects for the data contained in the Record object. Properties Contains all the Property information for the Record object. Stream Object The Stream object in ADO represents a stream of binary data or text. Although the Stream object was not covered in the chapter for ADO, it is included here for reference. Be aware that not all ADO providers support the Stream object. Properties for the Stream Object The following table lists the various properties of the Stream object. Property DataType Description Charset String Specifies the character set for the stream. EOS Boolean True if the current position is at the end of stream (EOS). LineSeparator LineSeparatorEnum Specifies the character or combination of charac- ters used as the line separator in the stream. Mode ConnectModeEnum Specifies the permissions for modifying data in the Stream object. Position Long The current position in the stream. Size Long Specifies the current size of the stream of data. State ObjectStateEnum Specifies the current state of the Stream object. Type StreamTypeEnum Specifies the type of data stored in the Stream object. 887 Appendix E: ADO Object Model Reference 47033bapp05.qxd:WroxProgRef 3/30/07 12:29 AM Page 887 [...]... the permissions 90 3 47033bapp06.qxd:WroxProgRef 3/30/07 12: 29 AM Page 90 4 47033bapp07.qxd:WroxProgRef 3/30/07 12:30 AM Page 90 5 The Access Object Model By now you’ve probably read at least a few of the chapters in this book and have realized that there are a lot of tasks you can accomplish by programming in VBA One concept that should be abundantly clear is that to use VBA to manipulate Access, you need... that represents the security mode Access uses when opening files BrokenReference 90 6 Data Type Boolean True if the current database has any broken references to databases or type libraries 47033bapp07.qxd:WroxProgRef 3/30/07 12:30 AM Page 90 7 Appendix G: The Access Object Model Property Data Type Description Build Long Build number of the currently installed copy of Access CodeContextObject Object Determines... possible values CurrentProject CurrentProject object Accesses the CurrentProject object DBEngine DBEngine object Returns the instance of the Access database engine and its related properties and collections DoCmd DoCmd object Returns the DoCmd object that contains many methods commonly used in Access FeatureInstall MsoFeatureInstall Determines or specifies how Access handles calls to methods or properties... Determines the object in which a macro or VBA code is executing CodeData CodeData Accesses the CodeData object CodeProject CodeProject Accesses the CodeProject object COMAddIns COMAddIns collection References the current COMAddIns collection object CommandBars CommandBars collection References the CommandBars collection CurrentData CurrentData object Used to access the CurrentData object CurrentObjectName... raised from Access macros MenuBar String Specifies the MenuBar to use for an Access database Table continues on the next page 90 7 47033bapp07.qxd:WroxProgRef 3/30/07 12:30 AM Page 90 8 Appendix G: The Access Object Model Property Data Type Description Modules Modules collection Returns the collection of open modules in a database Name String Returns the name of the application: Microsoft Access NewFileTaskPane... object with the following code: Application.CompactRepair “C:\DB\Samples.mdb”, “C:\DB\SamplesCompacted.mdb” 90 8 47033bapp07.qxd:WroxProgRef 3/30/07 12:30 AM Page 90 9 Appendix G: The Access Object Model Method Arguments Description AccessError ErrorNumber Returns the error message associated with an Access or DAO error number AddToFavorites None Adds the name of the current database as a hyperlink address... MEMBER_CAPTION MEMBER_TYPE Tree operator (For more information, see the OLE DB for OLAP documentation.) adSchemaPrimaryKeys adSchemaProcedureColumns 898 PK_TABLE_CATALOG PK_TABLE_SCHEMA PK_TABLE_NAME PROCEDURE_CATALOG PROCEDURE_SCHEMA PROCEDURE_NAME COLUMN_NAME 47033bapp06.qxd:WroxProgRef 3/30/07 12: 29 AM Page 899 Appendix F: ADO Object Argument Enumeration Information SchemaEnum Member Restrictions... user has to a database object As noted in Chapter 7, these method options are specific to MDB database files only SetPermissions()has no effect on the Access 2007 file format (ACCDB database files) 90 0 47033bapp06.qxd:WroxProgRef 3/30/07 12: 29 AM Page 90 1 Appendix F: ADO Object Argument Enumeration Information ObjectTypeEnum Members The ObjectType option specifies the type of object to which the permission... to maintain temporary data in a collection and pass data between Access macros and VBA code UserControl Boolean Determines whether the current Access instance was launched via automation VBE VBE object Returns an instance of the Visual Basic Editor Version String Returns the current version of Access Visible Boolean Returns True if the Access window is visible Application Object Methods The following... data Table continues on the next page 90 1 47033bapp06.qxd:WroxProgRef 3/30/07 12: 29 AM Page 90 2 Appendix F: ADO Object Argument Enumeration Information Members Value Description adRightDrop 256 The user/group has permission to remove objects from the catalog adRightExclusive 512 The user/group has permission to access the object exclusively adRightExecute 53687 091 2 The user/group has permission to execute . represent values. Table continues on the next page 8 79 Appendix E: ADO Object Model Reference 47033bapp05.qxd:WroxProgRef 3/30/07 12: 29 AM Page 8 79 Property DataType Description Size Long Indicates. next page 895 Appendix F: ADO Object Argument Enumeration Information 47033bapp06.qxd:WroxProgRef 3/30/07 12: 29 AM Page 895 SchemaEnum Members Member Value Description adSchemaTrustees 39 Returns. Specifies optimistic locking for batch updated. 891 Appendix F: ADO Object Argument Enumeration Information 47033bapp06.qxd:WroxProgRef 3/30/07 12: 29 AM Page 891 Options Argument Options arguments can

Ngày đăng: 09/08/2014, 12:22

Tài liệu cùng người dùng

Tài liệu liên quan