Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

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



0
alte
Asked:
alte
  • 3
  • 3
1 Solution
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now