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:
xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxx
Private Sub cmdPrevious_Click()
datTickets.Recordset.MoveP revious
If datTickets.Recordset.BOF = True Then
datTickets.Recordset.MoveN ext 'Same if MoveFirst
End If
End Sub
xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx
Experts, please help,
alte
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:
xxxxxxxxxxxxxxxxxxxxxxxxxx
Private Sub cmdPrevious_Click()
datTickets.Recordset.MoveP
If datTickets.Recordset.BOF = True Then
datTickets.Recordset.MoveN
End If
End Sub
xxxxxxxxxxxxxxxxxxxxxxxxxx
Experts, please help,
alte
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.Addne w ??
End if
If Not datTickets.Recordset.BOF Then
datTickets.Recordset.MoveP revious
End if
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.Addne
End if
If Not datTickets.Recordset.BOF Then
datTickets.Recordset.MoveP
End if
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.
As soon as datTickts.Recordset.BOF, the form gets empty and not even the Next button works.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help, but I'm using DAO, not ADO.
I'm testing with filled records.
I'm testing with filled records.
That part works the same for both DAO and ADO.
ASKER
I've followed your advice and now it works. Thanks a lot!
If Not datTickets.Recordset.BOF Then
datTickets.Recordset.MoveP
Else
datTickets.Recordset.MoveN
End If
AW