Article ID: 109710
Article Last Modified on 1/18/2007
'********************************************************
' Declarations section of the module
'********************************************************
Option Compare Database
Option Explicit
'**************************************************
' This function uses Seek on a two-field PrimaryKey
'**************************************************
Function SeekOnMultiFields()
Dim db As Database, tbl As Recordset
Set db = CurrentDB()
Set tbl = db.OpenRecordset("Order Details")
tbl.Index = "PrimaryKey"
tbl.Seek "=", 10300, 68
' If you are only supplying one value, the statement above
' becomes: tbl.Seek ">=", 10300
If tbl.NoMatch Then
MsgBox "Not a record. Try another"
Else
MsgBox "The Record is in the table"
End If
tbl.Close
End Function
In Microsoft Access 1.x:
'********************************************************
' Declarations section of the module
'********************************************************
Option Compare Database
Option Explicit
'**************************************************
' This function uses Seek on a two-field PrimaryKey
'**************************************************
Function SeekOnMultiFields()
Dim db As Database, tbl As Table
Set db = CurrentDB()
Set tbl = db.OpenTable("Order Details")
tbl.Index = "PrimaryKey" ' Or "Indexn" for other multi-field index
tbl.Seek "=", 10300, 68
' If you are only supplying one value, the statement above
' becomes: tbl.Seek ">=", 10300
If tbl.NoMatch Then
MsgBox "Not a record. Try another"
Else
MsgBox "The Record is in the table"
End If
tbl.Close
End Function
? SeekOnMultiFields()
Additional query words: multi-field index
Keywords: kbhowto kbprogramming KB109710