-
Jul 25th, 2017, 10:37 AM
#1
Thread Starter
New Member
.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
'''
-
Jul 25th, 2017, 10:48 AM
#2
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.
-
Jul 25th, 2017, 10:50 AM
#3
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.
-
Jul 25th, 2017, 04:11 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|