Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Recordset Seek - multiple fields

Recordset Seek - multiple fields

Scheduled Pinned Locked Moved Database
databaseregexquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    john john mackey
    wrote on last edited by
    #1

    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 >0

    rst.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

    L 1 Reply Last reply
    0
    • J john john mackey

      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 >0

      rst.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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I think it means that it should concatenate the fields, and search for that.

      MSDN[^] states:

      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:

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups