Results 1 to 2 of 2
  1. #1

    .Seek doesn't work in Recordset (A2K)

    I set the Index first, but everytime i try to use seek it says "Run-Time error 3251 - Object or provider is not capable of performing requested action."
    Maybe I'm using the wrong type of recordset, but I can't tell what the problem is...

    Appreciate any help!

    Here's the code, I also attached the file as well:

    Option Compare Database
    Option Explicit

    Private mrst As ADODB.Recordset
    Private mcnn As ADODB.Connection

    Private Sub Form_Close()
    'destroy the object variables
    On Error Resume Next
    Set mrst = Nothing
    Set mcnn = Nothing
    End Sub 'Form_Close()

    Private Sub List0_DblClick(Cancel As Integer)

    If mcnn Is Nothing Then
    Set mcnn = CurrentProject.Connection
    End If 'mcnn Is Nothing

    If mrst Is Nothing Then
    Set mrst = New ADODB.Recordset
    With mrst
    .ActiveConnection = mcnn
    .Source = "tblSelectedColors"
    .CursorLocation = adUseClient
    .CursorType = adOpenDynamic
    .LockType = adLockOptimistic
    .Open Options:=adCmdTable
    'set the index - i'm getting the error when it tries to set the index
    'as well as when it runs the seek command
    .Index = "ColorID"
    End With 'mrst
    End If 'mrst Is Nothing
    mrst!colorid = List0.Value


    End Sub 'List0_DblClick(Cancel As Integer)

    Private Sub List2_DblClick(Cancel As Integer)
    'I could use the following query to delete the record, but i need to use the recordset
    '(this is really just a sample database, I'm going to paste the code
    'into a larger project once i get it right)
    'DoCmd.SetWarnings False
    'DoCmd.RunSQL ("Delete * from tblSelectedColors where ColorID = " & List2.Value)
    'DoCmd.SetWarnings True

    mrst.Seek List2.Value, adSeekFirstEQ


    End Sub 'List2_DblClick(Cancel As Integer)

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Sacramento, California, USA
    Thanked 1 Time in 1 Post

    Re: .Seek doesn't work in Recordset (A2K)

    1) Seek only works on indexed fields when you've used the adCmdTableDirect option to open the recordset with a server-side cursor, and you can't use it on linked tables. If you want to use Seek, you have to open a direct connection to the back end first.

    2) You just deleted those records, so why are you doing a seek in the first place

    Take a look at the MS knowledgebase article <A target="_blank" HREF=>ACC2000: Using Seek Method with ADO Against a Jet Recordset [Q243465]</A> for more information on using Seek.

Posting Permissions

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