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 Fields: IsahFields_Object (R)
Property SQL: String (R/W)
Procedure Prepare
Procedure Unprepare
Procedure Open
Procedure Close
Procedure First
Procedure Next
Procedure Previous
Procedure Last
Procedure MoveBy( PositionNumbers : Integer )
Procedure ExecSQL
Function EOF: Boolean
Function BOF: Boolean
Function Lookup( [Caption: String], [Column: Variant], [Value: Variant] ): Boolean
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