?
Solved

Run-Time error 3426

Posted on 2003-02-20
7
Medium Priority
?
234 Views
Last Modified: 2010-04-07
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
Comment
Question by:alte
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 7988269
change it like this:

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


AW
0
 
LVL 3

Expert Comment

by:TimW1
ID: 7991049
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
 

Author Comment

by:alte
ID: 7993029
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
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.

 
LVL 3

Accepted Solution

by:
TimW1 earned 150 total points
ID: 8004758
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
 

Author Comment

by:alte
ID: 8024850
Thanks for your help, but I'm using DAO, not ADO.

I'm testing with filled records.
0
 
LVL 3

Expert Comment

by:TimW1
ID: 8028769
That part works the same for both DAO and ADO.
0
 

Author Comment

by:alte
ID: 8278400
I've followed your advice and now it works.  Thanks a lot!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question