Recordset Seek - multiple fields
-
if I use the Seek method with multiple criteria, does Seek use any of the fields to match or all fields must match? I have an ADODB Recordset. My syntax follows:
Dim cnn As ADODB.Connection
Dim rst As ADODB.RecordSet'set connection (assume correct)
Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset
rst.Open "MyTable", cnn, adOpenKeyset, adLockOptimistic, adCmdTableDirect'rst.index = "PrimaryKey"
'check if recordset valid - if rst.RecordCount >0rst.Seek fld_cmpr1 & fld_cmpr2 & fld_cmpr3, adSeekFirstEQ
Does this mean ALL 3 fields must match otherwise Seek result in rst.EOF?? (likewise, if this were DAO and i used rstDAO.Seek "=", fld_cmpr1..... do ALL fields must match?) Thanks! JJM
-
if I use the Seek method with multiple criteria, does Seek use any of the fields to match or all fields must match? I have an ADODB Recordset. My syntax follows:
Dim cnn As ADODB.Connection
Dim rst As ADODB.RecordSet'set connection (assume correct)
Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset
rst.Open "MyTable", cnn, adOpenKeyset, adLockOptimistic, adCmdTableDirect'rst.index = "PrimaryKey"
'check if recordset valid - if rst.RecordCount >0rst.Seek fld_cmpr1 & fld_cmpr2 & fld_cmpr3, adSeekFirstEQ
Does this mean ALL 3 fields must match otherwise Seek result in rst.EOF?? (likewise, if this were DAO and i used rstDAO.Seek "=", fld_cmpr1..... do ALL fields must match?) Thanks! JJM
I think it means that it should concatenate the fields, and search for that.
If you need to specify a value for more than one field, use the VBA Array function to pass those values to the KeyValues argument of the Seek method. If you only need to specify one value, it is not necessary to use the Array function.
Bastard Programmer from Hell :suss: