Run-Time error 3426

Hello there,

I'm getting this error message when clicking on the Back button of a very simple application and I don't know how to get rid of it.  (Application uses an Access DB(table) built with VB6.0 and a DataControl).

When clicking on the Back button, it works fine, but when BOF=True, then nothing happens and if I click once again, I get the "Run-Time error 3426 Accion was cancelled..."

I don't understand why I'm getting this error if there are no changes on the BOF that the control would try to save on the BOF.  I just want to move to the first record:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Private Sub cmdPrevious_Click()

datTickets.Recordset.MovePrevious
    If datTickets.Recordset.BOF = True Then
    datTickets.Recordset.MoveNext 'Same if MoveFirst
    End If

End Sub
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Experts, please help,

alte



alteAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Arthur_WoodCommented:
change it like this:

  If Not datTickets.Recordset.BOF Then
   datTickets.Recordset.MovePrevious
  Else
   datTickets.Recordset.MoveNext 'Same if MoveFirst
  End If


AW
0
TimW1Commented:
You shouldn't do a movenext without checking for .EOF.

How about:
If datTickets.Recordset.BOF _
     and datTickets.Recordset.EOF then
  Exit sub  'No records exist, don't move anywhere
  'Or you could do a datTickets.Recordset.Addnew ??
End if  
If Not datTickets.Recordset.BOF Then
  datTickets.Recordset.MovePrevious
End if
0
alteAuthor Commented:
It didn't work because the app gets blocked when going back to BOF and it happens in both of the codes you gave me.

As soon as datTickts.Recordset.BOF, the form gets empty and not even the Next button works.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

TimW1Commented:
You are using databound controls.  This is sometimes easier but far less functional.  Normally you should not use data bound.  Setup the data connection in code, query your recordset in code and have a Populate() sub that loads the current record you are on.  ADO recordsets are easy to use in code.

Also on your next button try.
if .EOF
  .Movelast
else
  .MoveNext
endif

on your previous button:
if .BOF
 .MoveFirst
else
 .MovePrevious
endif

Are you testing this with empty recordsets?  or is there data?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alteAuthor Commented:
Thanks for your help, but I'm using DAO, not ADO.

I'm testing with filled records.
0
TimW1Commented:
That part works the same for both DAO and ADO.
0
alteAuthor Commented:
I've followed your advice and now it works.  Thanks a lot!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.