Link to home
Start Free TrialLog in
Avatar of alte
alte

asked on

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



Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

change it like this:

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


AW
Avatar of TimW1
TimW1

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
Avatar of alte

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of TimW1
TimW1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of alte

ASKER

Thanks for your help, but I'm using DAO, not ADO.

I'm testing with filled records.
That part works the same for both DAO and ADO.
Avatar of alte

ASKER

I've followed your advice and now it works.  Thanks a lot!