Function Locate( KeyFields: String, KeyValues: Variant, Options: Integer): Boolean
Description
Searches the opened query for the first instance of a field matching the specified expression.
Parameters
0 = Case Sensitive + Whole Key
1 = Case Insensitive
2 = Partial Key
3 = Case Insensitive + Partial Key
Example
Sub Main()
Dim
SQL
Dim
Qry
Dim
Answer
SQL = "
Select LangCode, Description From Language
"
Set Qry = Application.DataBase.CreateQuery( SQL )
Qry.Open
' Position the record pointer on NL
Qry.Locate "
Language
", "
NL
" , 3
Answer = "
NL
"
If
Qry.LookUp("
Find a language
","
Language
")
then
' Use the fact that IsahFields_Object.Fields
' and IsahField_Object.Fields are default properties
Answer = Qry("
Language
").Value
End if
Qry.Close
' Another example but now with a double key
' Select 100 records from the prodbillofmat
Qry.SQL = "
Set Rowcount 100
" &_
"
Select ProdHeaderDossierCode, ProdBOMLineNr, LineNr From ProdBillOfMat
" &_
"
Set RowCount 0
"
Qry.
Open
' Go to the 35th record
For
i = 1
to
35
Qry.Next
next
' Save the line no. en prodheaderdossiercode of this record
ProdHeaderDossierCode = Qry("
ProdHeaderDossierCode
").Value
LineNr= Qry("
LineNr
").Value
MsgBox
"
Record to search for:
" & ProdHeaderDossierCode & " - " & LineNr
' Return to the first record and check whether it can be found using locate
Qry.First
SearchValues =
Array
(ProdHeaderDossierCode,LineNr)
if
Qry.Locate("
ProdHeaderDossierCode;LineNr
",SearchValues,3)
then
Qry.Lookup
end if
End Sub