Previous Topic

Next Topic

Inhoudsopgave

Book Index

CreateQuery Object

Function 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)

Function Procedure Prepare

Function Procedure Unprepare

Function Procedure Open

Function Procedure Close

Function Procedure First

Function Procedure Next

Function Procedure Previous

Function Procedure Last

Function Procedure MoveBy( PositionNumbers : Integer )

Function Procedure ExecSQL

Function Function EOF: Boolean

Function Function BOF: Boolean

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

Function 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