Results 1 to 4 of 4

Thread: .MoveFirst Error / record being deleted

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2017
    Posts
    1

    Unhappy .MoveFirst Error / record being deleted

    Hi, I hope this is the right place to ask you guys this question.

    I always get an Error Message like this:

    Either BOF or EOF is True, or the current record has been deleted.
    Requested operation requires a current record.

    Something is obviously wrong, but I don't know what it is.

    'Check if an exclusion has already been created in this Iteration
    Dim exlLstTemp As ADODB.Recordset
    Set exlLstTemp = New ADODB.Recordset
    exlLstTemp.ActiveConnection = CurrentProject.Connection
    'Open Stream to already created Exclusions
    Select Case model
    Case 166
    exlLstTemp.Open ("CRAIGLIST_166_Part_Exclusions_Append")
    pNrColumn = 3
    If Not (exlLstTemp.EOF) Then exlLstTemp.MoveFirst 'And Not (exlLstTemp.BOF)
    Case 205
    exlLstTemp.Open ("CRAIGLIST_205_Part_Exclusions_Append")
    pNrColumn = 2
    If Not (exlLstTemp.EOF) Then exlLstTemp.MoveFirst
    End Select
    exlLstTemp.MoveFirst

    'Loop through table
    Do While Not exlLstTemp.EOF
    If exlLstTemp.Fields.Item(pNrColumn) = teileNr Then
    isDuplicate = True
    End If
    exlLstTemp.MoveNext
    Loop
    exlLstTemp.MoveFirst
    '''


    Name:  Capture.jpg
Views: 997
Size:  46.5 KB

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: .MoveFirst Error / record being deleted

    Welcome to VBForums

    As your profile says "VB version: Access", I have moved this thread from the 'VB.Net' forum to the 'Office Development/VBA' forum. Note that while it certainly isn't made clear, the "VB Editor" in Office programs is actually VBA rather than some other variation of VB, so our other forums are not really apt.

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: .MoveFirst Error / record being deleted

    As to the error you are getting, simply remove that line of code... you don't need to .MoveFirst just after opening a recordset, because if there are any records then you will already be on the first record (so at best you would be doing nothing).

    You should also remove the "If .MoveFirst" lines in the Select Case above it, as they are equally pointless.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: .MoveFirst Error / record being deleted

    exlLstTemp.ActiveConnection = CurrentProject.Connection
    you should check after opening the recordset if there are any records
    Code:
    if not exlLstTemp.eof then
    if not eof run all the rest of the code for that iteration
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width