Previous Topic

Next Topic

Inhoudsopgave

Book Index

CreateQuery Object

Funktion Function CreateQuery( SQL: String ): Query_Object

Description

Creates a read-only Query object.

Remarks

The Query object allows read-only query access to the database. Please note that you cannot use the Query object to run updates. You can, however, use the CreateUpdateQuery function for this purpose.

Parameters

Result

Returns a Query object.

Properties, Procedures and Functions

Property Property Fields: IsahFields_Object (R)

Property Property SQL: String (R/W)

Funktion Procedure Prepare

Funktion Procedure Unprepare

Funktion Procedure Open

Funktion Procedure Close

Funktion Procedure First

Funktion Procedure Next

Funktion Procedure Previous

Funktion Procedure Last

Funktion Procedure MoveBy( PositionNumbers : Integer )

Funktion Procedure ExecSQL

Funktion Function EOF: Boolean

Funktion Function BOF: Boolean

Funktion Function Lookup( [Caption: String], [Column: Variant], [Value: Variant] ): Boolean

Funktion Function Locate( KeyFields: String, KeyValues: Variant, Options: Integer): Boolean

Example

Sub Main()

Dim Query

Dim SQL

Dim Answer

SQL = "Select LangCode , Description From Language"

Set Query = Application.DataBase.CreateQuery( SQL )

' Places the SQL statement on screen

MsgBox "The SQL statement is: " & vbcrlf & Query.sql

Query.Open

Answer = "EN"

IF Query.LookUp("Find a language","Language",Answer) then

Answer = Query("language").Value

MsgBox "The selected language is: " & Answer

End If

' Positions the query at the first record if it is not positioned at the beginning

If not Query.BOF then

Query.First

End If

' The query is now positioned at the first record

' Show the value of this field in a message box

MsgBox Query("CountryCode")

' Run the entire query and show all values

Do Until Query.EOF

' Show a value of the "Description" field

MsgBox Query("CountryCode").Value

' Proceed to the next record

Query.Next

Loop

' Close the query

Query.Close

End Sub