Undo is being cancelled by a call to bookmark?

G

Guest

I have isolated a strange problem having to do with a bookmark

I have a standard navigation routine that sets the command buttons on each
form. This was originally developed for MDB’s and worked fine. Since
converting to an ADP I am finding this strange problem. Aren’t they all?

The user clicks on an Undo button which performs a Me.Undo, foolowed by a
call to the standard navigation routine to enable/disable nav buttons. On
some forms in this ADP it works fine on other forms the UNDO is being
ignored/cancelled. Bet you thought that wasn’t possible? I sure did!

The line of code below is the culprit ! isolated by testing
( .Bookmark = ParentForm.Bookmark)

The routine is not generating an error it is just somehow cancelling the Undo

Any thoughts, ideas or clever discources? Thanks for your help!
RJ

Private Rst As ADODB.Recordset
Private RstAllowAdds As Boolean
Private CurrentNew As Boolean

Public Sub Set_Navigation_Buttons(ParentForm As Form, NavigationOption As
Long)

' This function enables and disables navigation buttons as
' necessary, depending on the current main form record
On Error Resume Next
If NavigationOption = 1 Then
'Form is Clean
ParentForm.FormSetfocus.SetFocus ' so we dont bump into
any focused buttons
ParentForm.cmdClose.Enabled = True
ParentForm.cmdWrite.Enabled = False
ParentForm.CmdUndo.Enabled = False
CurrentNew = ParentForm.NewRecord
RstAllowAdds = ParentForm.AllowAdditions

If CurrentNew Then
ParentForm.cmdNext.Enabled = False
ParentForm.cmdNew.Enabled = False
ParentForm.cmdPrev.Enabled = (Rst.RecordCount > 0)
Else
Set Rst = ParentForm.Recordset.Clone
With Rst
' Check Previous Record Ability
.Bookmark = ParentForm.Bookmark
.MovePrevious
ParentForm.cmdPrev.Enabled = Not .BOF

' Check Next Record Ability
.Bookmark = ParentForm.Bookmark
.MoveNext
ParentForm.cmdNext.Enabled = Not .EOF

'Check New Record Ability
ParentForm.cmdNew.Enabled = RstAllowAdds
.Close
End With
End If
Set_Toolbar_Enabled (True)
Else
'Form is Dirty so disable all but Write / Undo button
ParentForm.cmdWrite.Enabled = True
ParentForm.CmdUndo.Enabled = True
ParentForm.cmdClose.Enabled = False
ParentForm.cmdPrev.Enabled = False
ParentForm.cmdNext.Enabled = False
ParentForm.cmdNew.Enabled = False
Set_Toolbar_Enabled (False)
End If
End Sub
 
G

Guest

I still don't know what the original problem was but I found the following....

I took the code out of the Form_Undo event (which has the cancel option) and
moved it below the code for cmdUndo_Click and everything worked as expected.
The only differnece is that the Undo does not have the option to be
cancelled.

I truly don't see a difference here but at least I have a workaround. I am
interested in any comments however!

***************** DOESN"T WORK with Bookmark

Private Sub Form_Undo(Cancel As Integer)
Call Set_Navigation_Buttons(Me, 1)
End Sub

Private Sub CmdUndo_Click()
Me.Undo
'This implicity calls the Form_Undo events
End Sub

***************** DOES WORK with Bookmark
Private Sub CmdUndo_Click()
Me.Undo
Call Set_Navigation_Buttons(Me, 1)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top