Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    syntax for seek (xp/2k)

    What is the proper syntax for this code: I would like to search on the 2 indexes, but I cannot figure out the correct syntax.

    Dim rst As adodb.Recordset

    Set rst = Me.Recordset
    rst.Index = "intcemetary" ' the value seeking for is 3
    rst.Index = "txtgush" the value seeking for is A

    rst.MoveFirst
    rst.Seek ???? (What goes in here?)
    Debug.Print rst.Fields(0).name
    Debug.Print rst.Fields(0).Value

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: syntax for seek (xp/2k)

    You should set the index only once. If you want to seek on two fields, you mist have defined a composite index on the combination of the two fields in the table, in this example intCemetary and txtGush. In the VBA code, set the Index of the recordset to the name of the composite index.

    The first argument of Seek is an array containing the values you want to seek on. If you want to seek on intCemetary = 3 and txGush = "A", use

    rst.Seek Array(3, "A")

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: syntax for seek (xp/2k)

    can i create a composite index for this specific recordset, and if so how?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: syntax for seek (xp/2k)

    According to the online help, the index must be defined in the underlying table. There are no methods for creating an index on a recordset, as far as I know.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •