Understanding and Master Access - Experience

xiaoxiao2021-03-06  68

Abstract: This paper analyzes the differences between Access and XBase from the angle of XBase users and further expounds database objects and programming methods in Access.

---- Keywords: Access ---- FoxPro ---- Database

---- Microsoft has two popular desktop database development tools, one is the Windows-based ACCESS developed by its own development, and the other is the FoxPro obtained by which it is merged with Fox. DBASE, FOXBASE, FOXPRO, etc. are usually referred to as XBase has a large number of users in my country. With the rapid rise of Microsoft's Access in the international desktop market and the Chinese Office is in depth in my country, more and more users began to use. MsAccess (one of the Chinese Office97 components), many XBase users have also started to turn to Access for Microsoft. Due to Access's file organization, data type, programming language, programming method, etc.

There is a big difference with XBase, causing a lot of XBase users feel confusing when learning Access, some users are even just because they cannot find commands corresponding to XBase from Access, thus giving up Access's learning. . Compared with XBase,

Access has a lot of advanced features, once you master the basic concepts and programming methods of Access, change the "XBase's way of thinking", you can use the existing XBase knowledge to master Access. This paper compares XBase and Access from many aspects, by comparing traditional XBase users better understand and master Access.

----, the main differences between Access and XBase:

---- From a big aspect, Access uses and programming methods

The use of Visual FoxPro 3.0 and Visual FoxPro5.0 is very similar, familiar with Visual FoxPro 3.0 and above

Accounts are very easy to learn Access. No Visual

FoxPro's traditional XBase users start learning Access or Visual

When FoxPro, you need to make greater changes in your mind, because Access and Visual FoxPro are adopted by event processing and face.

Object design method. The XBase described below refers to the version below Visual FoxPro.

---- Document Organization Different: The system established with XBase usually contains many different types of files, each table, program, report, query, index, menu, etc. are all files, and can be stored on disk, and can pass project files Organize and manage other types of documents; Access is very similar to the database organization of the database, such as SQL Server, is very similar, different data or program elements are called objects, all

Objects are stored in a physical file, and this physical file is called a database.

---- Programming language Different: In traditional XBase, table, record and other data manipulation or interface design use the XBase command to program, the high version of FoxPro introduces some SQL statements (such as SQL-SELECT) main Used to complete data query; data operations in Access, records, and other data operations mainly through SQL implementation, program and event code, using Visual Basic for Application (Low versions of Access ACCESS BASIC), simple programming macro. Visual Basic is a more common programming language, and the MS Office component can be programmed with Visual Basic.

---- Programming method Different: The process-oriented programming method is used in XBase, even a user input interface design also requires a longer XBASE program; an object-oriented programming method is used in Access, the data processing function is completed. By changing the object of the object or implementing the object method, the block typically constitutes an event process, an object method, a function, and a continuous long program in Access will occur. In addition, there is a field level, record stage, table-level data reference integrity data constraint function, transaction function, and complete security mechanism.

----, database objects in Access

---- ACCESS Database window contains six different database objects, which are tables, query, form, report, macro (MACRO), and MODULE. . Access's database contains all data like a container

Library objects, different accesss with FoxPro project files

Like stored in a file. Creating a database object Simply click the 'New' button in the Database window to modify the existing object selection object and then click the 'Design' button.

---- Table in Access: The table in Access is equivalent to DBF files in XBase or the database table in Visual FoxPro. Access table

The DBF file with XBase has the next new feature:

Field name can be 64-bit characters

You can set the input mask of the field, the default value, and the value range. The role of Picture, Default, Range, and other clauses in the @? Etc statue is quite used in XBase. You can set the relationship between fields and fields (by setting table properties)

---- In Access, you do not need to create and maintain index files with special commands or operations. Establish an index according to a field, simply select a specific index type in this field index property, indexing and maintenance and Use the Access system to be done, in XBases: Index ON, SET INDEX TO, etc. Does users do not have to care.

---- You can create multiple tables in Access's database, and you can build a so-called reference integrity relationship between the tables and the tables, such as multi-pair one and pair created with SET RELATION in XBase, set SKIP commands. Like the relationship, Access can complete a pair of and multi-to-one relationships and ensure the validity of the relationship between the records in the relevant table by chain and chain update to ensure the validity of the relationship between the relevant tables, and cannot be accidentally deleted or changed. related data.

---- An important thing to use the Access table with the DBF file using XBase

The difference is the so-called "open" concept, and XBase is used to open the DBF file in XBASE to provide data channels in the memory establishment data buffer. If you want to view the data in the DBF file, you need to use the browse or other commands, open one in Access Table is equivalent to the use beowse command in XBase. Processing data in the table does not display records in the table, usually there is two mid-actions in Access, one is to update or change data with SQL statements, and do not need to open the table after performing SQL statements; the other is to use VBA Programming Through Data Access Objects (DAO) to manipulate the table, when you operate through the DAO manipulation, you want to open the so-called record set (RECORDSET), the use of the use command in XBase is similar to the role of the OpenRecordset method in the VBA (Visual Basic for Application).

---- Query: The query in Access is SQL data manipulator, using queries to view, change, and analyze data through different methods, equivalent to SQL SELECT statements in FoxPro and the query of FoxPro. In Access, most of the tables, records, fields can be done by queries, for example: using a lot of replace ... with ... commands in XBase, in Access, use actions to complete (SQL Update ). Establishing and using queries in Access is basically equivalent to using SQL commands in the background database (such as: Oracle, SQL Server), the SQL of the Microsoft Jet Database Engine complies with ANSI SQL, Access

SQL implements almost all ANSI SQL features, some SQL commands

There is nothing in ANSI SQL.

---- Access Squiry is more convenient and flexible than the SQL SELECT command in FoxPro, in Access, select the query is equivalent to the table, can establish a relationship between the table and the query, the query can also be used as a table Source of forms and reports, and use queries to build a query.

---- Form: The form is the main interaction interface of the system using Access. In some books, the form is called a form, the form is equivalent to using the @? Ay? Et command written in XBase. A program that implements a so-called full-screen editing function, the form is similar to the screen file (.scx) in FoxPro. The establishment of a human-machine interaction interface in Access is as needed to create a form object in FoxPro.

--- Report: ACCESS report objects closest to report files (FRX, FRM) in XBase. Establish a report file in XBase

After you need to preview or print the report with the Report Form ..., you can click the 'Open' button preview report in the database window after the report object is created, or use the OpenReport command to print or preview the report in the macro or module.

---- Macro (Macro): Macro refers to a collection of one or more operations, each of which implements a specific function, such as open a form or prints a report. Macros can automate certain ordinary tasks. For example, a macro can be set, run the macro when the user clicks a command button to print a report. There is no specific file type in XBase corresponding to the macro of Access, in the Access 97 and below, using macro to create

Household custom menu.

---- Module: ACCESS module is equivalent to program files and process files in XBase. Each module can contain one or more subroutines, functions, or attributes, and the subroutine is equivalent to the process in BASE.

----, User Interface Design in Access

---- In the development of information systems, the user interface is designed to have a large workload. User Interface Design in Access is greatly simplified than user interface in XBase, and the user interface in the early XBase version needs to determine the coordinate position where the text is displayed on the screen. Then the user @? AY? Et commands; FoxPro, user interface The design has a large improvement, when designing the user interface, set the screen file (.scx), then generate the program file (.spr) for the user interface with the generator. Create a user interface to establish a database of databases (FORM), FORM's establishment and design and most Windows-based development tools (such as: VisualBasic) consistent, with large differences in XBase user interface, XBase Users should understand and grasp the form design of Access from the following aspects:

---- 1. Understand the form and procedure

---- FoxPro, establish a user-interactive interface to create a screen file, and include a number of code segments (CODESNIPPET), using the generator to generate a program file with SPR based on the screen file, the code snippet is included in the program In the file, the execution program file is an interactive user interface. ACCESS, the form is equivalent to the screen file, the form has three different views (View) - design views, form views, and data table views. The design view mode is used to design or modify the form. After the form is designed, you can open the form to the interactive interface used for the user to operate in a form view or data table view. There is no need to generate a program code in Access, and the form is opened directly or switch to the form view after the form is built. One of the other people in FoxPro is one of the people's headaches is to repeatedly modify the screen while debugging the screen.

The curtain, generate program code, execute program viewing running effect, any minor change to screen files must be generated by generating programs, executing programs can see the result, there is no need to generate a process in Access, just switch between design view and form view. You can know the effect after the form is modified.

---- Form Module and Event Process: In FoxPro, @? Et, read, activate, etc., there are many clauses, such as: the most common VALID clause, clause usually customize with one user Function, when establishing a screen file with the screen generator, the content of the custom function after the clause can be input directly, and the custom function block used by these clauses is referred to as a code segment (CODESNIPPET). ACCESS, the program segment corresponding to the codes in FoxPro is an event procedure. The so-called event process refers to an automated execution process that responds to events or systems triggered by the user or program code. . For example, if you want to perform a certain segment after entering or modifying the value of a field, you need to create a custom function you need to establish a Valid clause and a Valid clause by entering the code snippery; in Access, a control ( The value of Control will enter the program content during the event of the AFTERUPDATE event property of the control during input or modification. When the value of the control changes, the AFTER UPDATE event system will automatically execute the event. The event process. Each form in Access has a form module associated with the form. All event procedures for all the forms and the form of the form are stored, and the form is saved. The module is automatically saved.

---- 2. Understanding record Source (Record Source)

---- In FoxPro, you should open the relevant table before creating a screen file, establish a relationship between tables and tables, after the screen file is created, the system will ask if the system will save the environment (Environment), if you save the environment The open table is saved, and the generated program code contains a command to open and close the table. The "data environment" of the ACCESS is called a record source, the record source can be a table, query, or SQL SELECT statement. Access's record source is more flexible than foxPro's "data environment", when the recording source of the Access Form is related to each other, the Access is created by establishing a query or using the SQL SELECT statement as a record source And the query is specified related tables and intervals related to the SELECT statement .---- Create FoxPro's screen file to open the relevant table and save the "Data Environment" to include the program line, Access when the program is generated. The source of the form is just given the table, query the name, or SQL SELECT statement in the form of the form, and the record source does not generate program code. The form automatically handles the table, query and SELECT statement, and There is no command or statement to handle the table, the problem of the query.

---- 3. Understand control, attributes and event processes

---- The text box (TextBox), a list box (ListBox), such as the FoxPro screen generator interface, the corresponding memory variable or field variable, and the screen generator forms a number of settings such as text boxes. Many clauses of the @ ..Get statement generated such as: Enable, Disable, Font, Style, Default, Message, Range, Color, etc., the code snippet entered in the screen generator forms a customization in the program. Functions or processes and @? Etc statutes of Valid, When et al.

In Access, quite foxPRO is called control (Control) in the screen generator. The clause of the @? Etc is implemented in Access, for example:

@ .... get text disable statement in FoxPro, is in Access

Set the enabled attribute value of the Text Control to False (No); show get text enable in FoxPro Use the assignment statement me! Text.enabled = true in Access to change the properties of the Text Control. The code snippet in FoxPro is implemented by an event procedure, for example: foxPro @? Etc @? Et text valid check () statement contains the Valid clause and check () custom functions, achieving the same function in Access The Text Control Before Update (or After Update) Property Value Select '[Events]' and enter the corresponding program code. The common FoxPro @? ET statement is related to Access's control attribute correspondence is as follows:

FoxPro clause

Access control properties

FUNCTION

Format, Input Mask properties

Picture

Format, Input Mask properties

Font

Font Color Name Size Weight Italic Underline and other properties

Style

Font Italic underline and other properties

DEFAULT

Default Value

Enabled | Disable

Enabled

Range

Validation rule, Validation Textsize

Left, Top, Height, Width

Vilid

Before Update, After Update

WHEN

ON Enter, on Got Focus

---- 1. "Mobile Record Pointer" in the form

---- The user interface created by the FoxPro screen generator often contains a button for moving the record. By clicking the button changing the current record in the screen or window, the method implemented in FoxPro is generally at the Valid of the button variable. In addition to the function of the sentence, the pointer moves the statement such as SKIP, GOTO, LOCATE, etc. XBase users want to implement the same function when using the Access form, often do not know how to start, and the record navigation in the form can be recorded in the form:

Add a record navigation button (Navigation button) using the Goto Record Macro or Find Record Macro Use the Data Access Object (DAO) to change the current form.

---- If only the record is moved before and after in the form, no need to write a program, set the form's Navigation button value to True when the form is designed, and the navigation button will appear in the form. Tap the navigation button forward move, rear shift record. If you want to move the record to a specific record, you must be implemented by macro or VB programming, for example: Click the CMD button down in the form to enter the following VB statement during the CMD button on the CLICK event:

---- DOCMD.GOTORECORD ,,, 3

---- The following example uses the recordset in the current form to locate the record to "Name" field value? Zhang San "record:

DIM RST As Recordset

DIM STRSEARCHNAME AS STRING

SET RST = Me.RecordsetClone

Strsearchname = "Zhang San"

Rst.FindFirst "Name =" & Strsearchname

IF RST.NOMATCH THEN

Msgbox "Didn't find"

Else

Me.bookmark = Rst.Bookmark

END IF

Rst.Close

---- ME.RecordsetClone is a copy of the base query or base table specified by the form of the Form, Bookmark is a bookmark for record set, used to uniquely identify the form base table, base query, or SQL statement Specific record. In the example, the FindFirst method is positioned in the recordset copy of the form recording source, and then moves the position of the record of the form to the same location.

---- 壹, common commands in XBase implementation in Access

---- Many XBase users use Access to use Access to find out statements, functions, or implementation methods with XBase commands in Access, which gives the ACCESS macro commands corresponding to the common XBase commands and VB statements or implementations:

XBASE command

Access macro command

Access VBA statement

Access operation

Use

OpenRecordset method

Usually, it is not necessary, and the processing table record is used.

Browse / edit

OpenTable

DOCMD.OpenTable

Open the table directly in the database window

Index on

Specify the index properties of the table field

Sort on

Command over the toolbar or menu

Replace

Use SQL statements

Sum aVER, etc.

DSUM () et al.

Use SQL statements

Goto

Gotorecord

MOVE method

Use record navigation buttons

Skipgotorecord

MOVE method

Use record navigation buttons

Locate

Findfirst method

Find with filtering operations by toolbar or menu command

Total

Use SQL statements

, Data type in Access

---- XBase users are not adapted to the field type of the Access table when using Access, in the first time, especially the value field type. It is because of the lack of understanding of Access's data type, making many users have problems during the development process. The field type of Access and XBase table and its correspondence is shown in the following table:

The field type of the table in Access

XBase in the field type

Character type (Text)

Character

Value (short integer, long integer, single precision, double precision)

Numeric

Currency

Numeric

Memo (MEMO)

Memo (MEMO)

Date Time (Date / Time)

Date type (date)

Logical (YES / NO)

Logical

OLE Object (OLE Object)

General type

---- XBase User's first time to use Access, what is commonly encountered is the value field type problem in the Access table. Define the value field in XBASE DBF file to give the field type, width, and decimal number. When the recorded value field stores data, XBase only saves the specified number of decigits and automatically processes the number of questions, the numerical fields in the ACCESS are different from the XBASE's value field, and the field stores numeric data in the table. Set as a short integer, long integer, single precision, double precision, or monetary type, and the number of fixed lengths cannot be saved when saving data in the numerical field, nor can it automatically handle the number of decimal rounds. Although there are DECIMALPLACES and FORMATs in the field properties, these two attributes are only determined that the data is displayed instead of retaining a specific decimal number, and the user must process the number of decimal bits and roundabouts in the time of saving numerical data.

---- XBase User When using the Access table, you often encounter another problem is a NULL value problem of the field. In XBase, if the field is not input, the character field is a space string, the value field is zero; Access, if The field is not input to the value of the value of the field is null (null), NULL is the special constant in Access indicates no value, and NULL cannot give non-Variant variables. When accessing the recorded fields via the DAO, use the NZ () function to convert NULL to a character type empty string or a numeric zero value.

转载请注明原文地址:https://www.9cbs.com/read-109650.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.076, SQL: 9